cancel
Showing results for 
Search instead for 
Did you mean: 

How to check pre-processor output for macro expansion

matt-crc
Senior

Is there a way to see how CubeIDE is expanding/pre-processing this code?

typedef struct  {
	int16_t x;
	int16_t y;
	int16_t z;
} TouchPoint;

#define TS_Point(_x, _y, _z) { .x = _x, .y = _y, .z = _z }

TouchPoint Touch_FT6236_GetPoint(uint8_t n) {
	Touch_FT6236_ReadData();
	if ((touches == 0) || (n > 1)) {
		return ((TouchPoint)TS_Point(0, 0, 0));
	} else {
		return ((TouchPoint)TS_Point(touchX[n], touchY[n], 1));
	}
}

 Its compiling, but I'm getting weird values.

1 ACCEPTED SOLUTION

Accepted Solutions

@matt-crc wrote:

Is there a way to see how CubeIDE is expanding/pre-processing this code?.


Note that CubeIDE itself does do the expanding/processing - it's done by the preprocessor during compilation.

But the option you require is here:

AndrewNeil_1-1743413692593.png

 

 

 


@matt-crc wrote:

I'm getting weird values.


So what are you expecting to get?

And what do you actually get?

 

View solution in original post

5 REPLIES 5
mbarg.1
Senior II

Best - according to my experience - use MENU Window->Show View->Include Browser


@matt-crc wrote:

Is there a way to see how CubeIDE is expanding/pre-processing this code?.


Note that CubeIDE itself does do the expanding/processing - it's done by the preprocessor during compilation.

But the option you require is here:

AndrewNeil_1-1743413692593.png

 

 

 


@matt-crc wrote:

I'm getting weird values.


So what are you expecting to get?

And what do you actually get?

 


@mbarg.1 wrote:

use MENU Window->Show View->Include Browser


That doesn't show preprocessor output - does it?

@Andrew Neil 

I originally tried that, but didn't find the pre-processor output.... Eventually, i figured out that the *.o object files contained the expanded C code.  (not obvious)

@mbarg.1 

I think that option only displays the include hierarchy.


@matt-crc wrote:

I originally tried that, but didn't find the pre-processor output.... Eventually, i figured out that the *.o object files contained the expanded C code.  (not obvious)


The standard command line tells the compile to call its output file .o

So, when the generated output is the preprocessor output, it goes into the .o file.

Indeed, it makes sense once you know - but it's not obvious before you've found out!

There's also the -save-temps option to do the compile and keep the preprocessor output:

https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#index-save-temps

 


@matt-crc wrote:

@mbarg.1 

I think that option only displays the include hierarchy.


It also shows call/caller hierarchy

But, indeed, not preprocessor output.