preprocessor

Difference between cpp and gcc -E

穿精又带淫゛_ 提交于 2020-06-11 20:58:06
问题 I thought that both cpp foo.c and gcc -E foo.c do preprocess the source file the same way, but I got their output to differ for the same file. $ cat foo.c #define VARIABLE 3 #define PASTER(x,y) x ## _ ## y #define EVALUATOR(x,y) PASTER(x,y) #define NAME(fun) EVALUATOR(fun, VARIABLE) extern void NAME(mine); Result for cpp : $ cpp foo.c # 1 "foo.c" # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 329 "<built-in>" 3 # 1 "<command line>" 1 # 1 "<built-in>" 2 # 1 "foo.c" 2 extern void mine ## _ ## 3; $

Difference between cpp and gcc -E

不想你离开。 提交于 2020-06-11 20:58:01
问题 I thought that both cpp foo.c and gcc -E foo.c do preprocess the source file the same way, but I got their output to differ for the same file. $ cat foo.c #define VARIABLE 3 #define PASTER(x,y) x ## _ ## y #define EVALUATOR(x,y) PASTER(x,y) #define NAME(fun) EVALUATOR(fun, VARIABLE) extern void NAME(mine); Result for cpp : $ cpp foo.c # 1 "foo.c" # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 329 "<built-in>" 3 # 1 "<command line>" 1 # 1 "<built-in>" 2 # 1 "foo.c" 2 extern void mine ## _ ## 3; $

NASM Assembler, how to define label twice?

﹥>﹥吖頭↗ 提交于 2020-05-23 10:53:54
问题 I have different "*.asm" files that need to be included in the "main.asm" file. The problem I'm facing is that: In many files I have declared labels like "loop", "forLoop", "whileTag" etc... in the same way ( i.e. with the same name ) And when I try to %include "file1.asm" and %include "file2.asm" it gives me a compilation error. It says that I can't declare the same label twice ( i.e. file1.asm and file2.asm, both have "loopHere" label declared ). How do I solve this ? Thanks The problem

NASM Assembler, how to define label twice?

本小妞迷上赌 提交于 2020-05-23 10:53:03
问题 I have different "*.asm" files that need to be included in the "main.asm" file. The problem I'm facing is that: In many files I have declared labels like "loop", "forLoop", "whileTag" etc... in the same way ( i.e. with the same name ) And when I try to %include "file1.asm" and %include "file2.asm" it gives me a compilation error. It says that I can't declare the same label twice ( i.e. file1.asm and file2.asm, both have "loopHere" label declared ). How do I solve this ? Thanks The problem

C++ __FILE__ macro with absolute path

倾然丶 夕夏残阳落幕 提交于 2020-04-16 02:09:43
问题 I am trying to get the absolute path of the compiled file at compile time in C++. I am aware of the __FILE__ macro - however, the macro can be evaluated to either absolute path, or a relative path, depending on the preprocessor's arguments. I would like to ensure that my __FILE__ (or any other macro) evaluates to a full, absolute path of the file. Is there a way to reliably do it cross-platform? (I am compiling for VS2013, VS2015, GCC on ubuntu, GCC on MinGW) 来源: https://stackoverflow.com