Context: Long time programmer, coming back to C as a baby. Apologies for what are probably obvious to you questions.
Can I apply macros to a C program without compiling it?
My understand of C Macros: They process your source file before handing it off to be compiled
Me: Here's my file
Compiler: OK, let me apply the macros get something I can compile
Compiler: OK, macros applied, lets compile this
Is there a way to view the program file that's actually passed off for compilation? i.e. a way to apply the macros but not compile the program.
For example, I have a small program that uses the PRIxPTR
macro.
#include <stdio.h>
#include <stdint.h>
//needed for the PRI*PTR Macros
#include <inttypes.h>
int main()
{
int i = 42;
int* pI = &i;
printf("iP points to address (base 16): %" PRIxPTR "\n", (uintptr_t) pI);
printf("iP points to address (base 10): %" PRIdPTR "\n", (uintptr_t) pI);
}
Compiling and running the program
$ cc main.c; ./a.out
produces the following output
iP points to address (base 16): 7fff545f587c
iP points to address (base 10): 140734608922748
I would like to see the C source that PRIxPTR
macro actually produces.
This seems like it would be possible -- is it? If not, is my understanding of macros incorrect? Or is there something else that prevents this from happening?