Hi All
I need to force the compiler to compile a code block that is seemingly meaningless, something like this:
int iEAX = 0x30313233;
int iEBX = 0x31323334;
int iECX = 0x32333435;
int iEDX = 0x33343536;
Those variables will not be referenced anywhere in the code below them, I just need them to be compiled.
As you can see I'd like those statements to be translated as something like:
mov EAX, 30313233H
etc, but that'd be too much to ask so I'd be happy if I can only get those constants into OBJ file exactly at the spot I've defined the unreferenced variables regardless of the instructions they are involved in.
It's easy if I disable the optimizations but that's not the point, that block has to be compiled regardless of the optimizations applied. If there was a
#pragma
that can disable the optimizations just for that specific spot, but there isn't... (I think)
You might guess that I need those constants to identify that spot in the OBJ file (after it gets compiled) and replace them with some binary code compled by other means.
That recuires if I have this case:
inline void func(int i)
{
int uv1 = 0x12345678;
int uv2 = i;
int uv3 = 0x87654321;
}
It has to be translated as something like:
mov EAX, 12345678H
mov EBX, dowrd ptr [ESP + "offset"] ; that's the formal argument 'i'
mov ECX, 87654321H
It doesn't have to be exactly like this, the point is the binary code to be surrounded by these constants.
Also it is not necessary those to be int constants, they could be static strings or whatever I can use to identify the spot where the function was inlined (in the OBJ file).
It's not secret why I want this, I just want to keep the TC short. If somebody is curious just ask me I'll tell you! ;) :D
Thanks a lot in advance! :)
P.S. I assume people are aware of that those blocks would normaly be skipped. Actually I did everything I could get to mislead the compiler to compile that bolck and a function similar to that I've shown but it keeps skipping them... :)