I'm interested in trying to see the assembly code for my header file. Playing around with a simple .cpp file with a dummy main method and compiling it is easy: g++ -S -o prog.exe main.cpp
However, I'm going into header files now. I have a dummy header file func.hpp
that just contains a dummy method and now I want to be able to compile it and see its assembly in a .S file. (The main reason for this is so that if I have a more complicated function, maybe I can do some manual optimization in assembly and just build the final executable through g++ -o prog.exe func.S main.cpp
.
However, I am not able to find sources that explain this. If I try g++ -S -o func.S func.hpp
I get an error message output filename specified twice
. Can anyone help me with this?
For reference, here is func.hpp:
int number()
{
return 0;
}
I'm also trying it out with another hpp file named struct.hpp:
struct Coord
{
int x;
int y;
};
Same error for both, but I want to be able to see the assembly for both headers without converting them to .cpp files (because that breaks the meaning of a header file.)