User Profile

Collapse

Profile Sidebar

Collapse
dissectcode
dissectcode
Last Activity: May 14 '12, 02:32 PM
Joined: Jul 17 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • dissectcode
    started a topic Using a variable from another class.
    in Java

    Using a variable from another class.

    EDIT: my title should have said "Define enum data type in one class and use in another" sorry


    i know, create a getter method but what i need to do is like in C, how we use headers to define data types and include that header, i want to define an enum in a java class only once and use it everywhere in my package. here is my example :

    Code:
    public class WlanLayer {
    	
    	/** Enum of status flags
    ...
    See more | Go to post

  • dissectcode
    started a topic Printing a string in this weird way.
    in C

    Printing a string in this weird way.

    Hi this is probably a stupid question, but I don't understand why the "&" prints the text (beginning at index 2 of course), isn't & an address??

    Code:
    #include <stdio.h>
    
    int main() 
    {
       char *str = "the brown fox";
       printf("what is it:  %s \n", &(str[2]));
       return 0;
    }
    result:
    ...
    See more | Go to post

  • dissectcode
    replied to Testing for regex match in array.
    in Perl
    thank you. i worked on it more this morning and found that because i included a whitespace character in my regex parameter (\s*\w) the space made it a different word than just the word itself, so eq would never be true.
    See more | Go to post

    Leave a comment:


  • dissectcode
    started a topic Testing for regex match in array.
    in Perl

    Testing for regex match in array.

    Hi: I'm stuck! I've tried a thousand things from forum suggestions...I need to parse the unit from a value and test that it exists based on known units (its not for school, its Jan 1..)

    Code:
    #/usr/bin/perl 
    
    my @unit = qw(mV V mA uA A K m uV nA nV pA pV); 
    
    while( defined($line = <LOGFILE>) )
    {  
       if( $line =~ /d+(\s*\w+)/ )
       {
           # now test if match exists!
    ...
    See more | Go to post

  • What is the default type & size of a numeric constant in C?

    If I have a function

    Code:
    funct( uint32 x )
    {
     stuff
    }
    and call it:
    Code:
    funct( 3 );
    what is the type and size of 3? Is it a long unsigned integer? Or 16 bits or what?

    What happens if I call:

    Code:
    funct( -3 );
    ? Will the -3 be converted? I know this should be common knowledge but I can't find this...
    See more | Go to post

  • dissectcode
    started a topic Using the '&' operator to show a value is odd ?
    in C

    Using the '&' operator to show a value is odd ?

    How does this work? Also - what about showing a value is even?

    eg:
    Code:
    int val = 3;
    if ( val & 1 ) print("I am odd");
    thank you
    ps this is not homework
    See more | Go to post

  • I think what I am trying to do can only be done using actual C code in functions since the name will depend on run-time inputs. I am using to it access HW registers. Please look at how the word "name" has certain letters in CAPS, or not.

    Code:
    #define REG_ADDR            ((void *) (0x00054000))
    
    #define REG_CASTADDR   ((Name *)(REG_ADDR))
    
    #define RD_REG(name, reg)    NAME##_CASTADDR->name##reg.myUint)
    ...
    See more | Go to post

    Leave a comment:


  • dissectcode
    started a topic Definition of 'int' on different platforms.
    in C

    Definition of 'int' on different platforms.

    I know on some operating systems, an int is the same as a short, while on others, an int is the same as a long. It depends on the word size of the operating system.

    Does anybody know what the definition of int in C is for linux, windows, cygwin etc?
    See more | Go to post

  • Thank you for your response. After looking through this code and concept - I am concerned that I cannot create a more general macro for any input during run-time....since it is a preprocessor thing, it does the concatenation at compile-time. Is this true?...
    See more | Go to post

    Leave a comment:


  • I need to change "name" to Name for the cast, and make sure it is in lower case for the structure name.

    Also - "name" is arbitrary so I couldn't typedef it to one thing ?
    See more | Go to post

    Leave a comment:


  • This is definitely on the right track - to answer your question, I need to change to upper case, AND lower case in the same macro.

    For example:

    Code:
    #define mac(name, val)  (Name *)(name->myMember.anum) = val
    See how name input is Name AND name in the macro?...
    See more | Go to post

    Leave a comment:


  • This would be done over 50 files, and they are needed to be capitalized in order to feed the word in the proper format, as an input into another macro.

    I would like to keep this in a C header file.
    See more | Go to post

    Leave a comment:


  • MACRO to capitalize first letter of a word in header.

    I know about toupper() and tolower() but I need to capitalize (or de-capitalize)the first letter of a word in a header file. I know there are no preprocessor functions that do that but is there another way?
    See more | Go to post

  • dissectcode
    replied to Flip from little endian to big endian ?
    in C
    Why?

    Because when we display results from an address, they are reversed, depending on the platform.
    See more | Go to post

    Leave a comment:


  • dissectcode
    started a topic Flip from little endian to big endian ?
    in C

    Flip from little endian to big endian ?

    Is there a quick method to flip endian-ness in C? Different platforms I am using, use big and little endian, and I want to flip everything to big.
    See more | Go to post

  • dissectcode
    started a topic How to combine TWO 32-bit words into one word.
    in C

    How to combine TWO 32-bit words into one word.

    Hi - I have a count register, which is made up of two 32-bit "words" - one for the high half of the value, and other for the lower 32 bits of the value.

    What is the best way in C to combine these two values - I just want to stick them together so they are one large number, and then display them.
    See more | Go to post

  • Thanks guys!! We are convinced of moving away from bit fields - and I will work on your suggestions now...
    See more | Go to post

    Leave a comment:


  • Like this?? :

    Code:
    typedef struct {
    
      uint32_t reg1 : 25;
      uint32_t reg2 : 5;
      uint32_t reg3 : 2;
    
    } volatile RegStruct;
    Right now I have the same, but the reg types are 'unsigned' instead of 'uint32_t'
    Will that make it access the registers by words not bytes?...
    See more | Go to post

    Leave a comment:


  • Forcing compiler to access bitfields as 32-bits instead of bytes.

    In my code, I have bit fields in structures to access hw registers. I tested my compiler to see how it reads/writes to the registers and noticed that the compiler is trying to access the registers by bytes. The HW registers only allow 32-bit "words" to be written or read, otherwise it will give a "bus error".

    Is there a way to force the compiler to produce WORD (32bit) accesses for bitfields instead of byte??
    See more | Go to post

  • dissectcode
    replied to Efficiency of int vs. unsigned int.
    in C
    I found an answer to this question in case anyone else needs to know. The docs of the processor only discuss front end stuff. So, to test the behavior of the entire compiler, create global variables of signed and also unsigned, and create for loops for each type. Run the compiler with a switch (-S for ARM) which gives the assembly language output. In the output, you can see the instructions for each of the loops, and how the compiler processes the...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...