C Preprocessor: concatenate int to string -


How do I figure out I can add a #define 'd rounded to a I'm trying to C using the preprocessor #define 'The string GCC 4.1 solution on my compiler CentOS 5 should also work for MinGW.

I would like to modify a version number on a string, but the only way that I would define as a copy wires of the version number to make sure you can get it to work is.

The closest thing I could find was a method of quoting macro arguments, but it #define s does not

It does not work Does.

  #define MAJOR_VER 2 #define MINOR_VER 6 #define MY_FILE "/home/user/.myapp" #MAJOR_VER #MINOR_VER   

without # s does not work because these values ​​are numbers and it will expand on "/ home / user / .myapp". >, Which is not valid C .

This works, but I do not like to define copies of this edition because I also need numbers in them. / P>

  #define MAJOR_VER 2 #define MINOR_VER 6 #define MAJOR_VER_STR "2" #define MINOR_VER_STR "6" #define MY_FILE "/home/user/.myapp" MAJOR_VER_STRING MINOR_VER_STRING    

classical C preprocessor question ....

  # defined STR_HELPER (X ) #x #define STR (X) STR_HELPER (x) #define MAJOR_VER 2 #define MINOR_VER 6 #define   < P> Additional level of indirection will allow the preprocessor to expand macros before converting into wires.   

Comments