3

This is the first question in stackoverflow. So far I got so many help from here. Thanks!

I have the following simplified code:

#define str(s) str2(s)
#define str2(s) #s
#define T_A linux-x86_64

const char* target_arch  = str(T_A);

#include <stdio.h>
void main() {
  printf("%s\n", target_arch);
  int i = 0;
  for (i=0; i< sizeof(str(T_A)); i++) {
     printf("%c", str(T_A)[i]);
  }
  printf("\n");
  return;
}

I expect something like:

linux-x86_64
linux-x86_64

However, it returns

1-x86_64
1-x86_64

Why do I get 1 instead of linux?

Han
  • 31
  • 2
  • https://stackoverflow.com/questions/19210935/why-does-the-c-preprocessor-interpret-the-word-linux-as-the-constant-1 –  Oct 12 '17 at 16:09

0 Answers0