Quantcast
Channel: C Pre-Processor Macro code with () and {} - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Afshin for C Pre-Processor Macro code with () and {}

$
0
0

Remember, pre-processor just replaces macros. So in your case you code will be converted to this:

#include <stdio.h>int main(){    unsigned int c = (1,2,3);    unsigned int d = {1,2,3};    printf("%d\n",c);    printf("%d\n",d);    return 0;}

In first case, you get result from , operator, so c will be equal to 3. But in 2nd case you get first member of initializer list for d, so you will get 1 as result.

2nd lines creates error if you compile code as c++. But it seems that you can compile this code in c.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>