c - Regarding macros -


I know what is the problem using the X-macro code

  define # FILL_BUFF_1 (int *) (0x01, 0x02) #define FILL_BUFF_2 (int *) (0x03, 0x04) #define X (A, B) #define LOOK_UP \ X (0x13, FILL_BUFF_1), \ x (0x14 , FILL_BUFF_2) # Undef X #define X (a, b) An int pid_table [2] = {LOOK_UP}; #undef x #define x (a, b) b int * pid_buff_ptr [2] = {LOOK_UP}; Zero main (int argc, _TCHAR * argv []) {printf ("% d", (pid_buff_ptr + 0)); // displayed 0x02 printf ("% d", (pid_buff_ptr + 1)); // displayed 0x04 printf ("% d", * (pid_buff_ptr [0] + 1)); // do not work}  

How do I create code above to access other elements in buffer?

I'm not sure what you're trying to do, but if I'm right properly estimated, you pid_buff_ptr includes an array of variable

If so, you

  # need to change, FILL_BUFF_1 (int *) (0x01, 0x02) #define FILL_BUFF_2 (int *) (0x03, 0x04)  

  #define FILL_BUFF_1 define {0x01, 0x02} #define FILL_BUFF_2 {0x03, 0x04}  

the following changes:

  int * pid_buff_ptr [2] = {LOOK_UP} ;  

to

  int pid_buff_ptr [] [2] = {LOOK_UP};  

To print, you will do some experimenting:

  printf ( "% d", pid_buff_ptr [0] [1]);  

Of course, I could be wrong.

Now, some other comments:

  • You must include the #lt; Stdio.h & gt; before using printf ()
  • main () return integer ..
  • Since returns int , you should return it to int Traditionally, 0 means success.
  • code I do not know what <> _TCHAR , but if it is an alias or not #define > char , You may have trouble in

Along with the above changes, I do not understand the need to sneak past -Processor. What are you really trying to do?


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -