代码:
#include <stdio.h>
int main(int argc, char* argv[]){
#ifdef __cplusplus
printf("this is cpp\n");
#endif
printf("Hello, world!\n");
return 0;
}
运行:
ongonginging@ongonginging-virtual-machine:~$ gcc test.c
ongonginging@ongonginging-virtual-machine:~$ ./a.out
Hello, world!
ongonginging@ongonginging-virtual-machine:~$ g++ test.c
ongonginging@ongonginging-virtual-machine:~$ ./a.out
this is cpp
Hello, world!
ongonginging@ongonginging-virtual-machine:~$