I too get a working exe this way (win2k).
But the following warnings:
warning #2135: Static 'szShared' is not referenced.
warning #3122: [asm] Redefinition of section '.drectve'; ignored.
I don't understand that.
If the redefinition of .drectve would really be ignored the 'run once' feature would not work.
The warning #2135 tells you that you declared a static variable that is not used in current file. But this declaration was intended to 'write' in .drectve section the linker command.
For error #3122 I'm not sure about what the message would be. The linker command changes the attributes of 'Shared' section, not that of the '.drectve' section. No change must be done to this section that, as I already told is only for compiler->linker communication and will never be inserted in final PE.
Using the correct form you have to remove all three lines:
#pragma data_seg(".drectve")
static char szShared[] = "-section:Shared,rws";
#pragma data_seg()
And why is the #pragma comment(linker, "-section:Shared,rws")
variant not working?
Edit: No, after selecting a new resolution I wanted to change it back and the menu comes not up. And one times the #pragma comment(linker, "-section:Shared,rws")
variant was working.
You are messing something there... The one above is the
correct form and works!
If I use
#pragma comment(lib, "pocrt.lib")
at the beginning of the file I get
POLINK: fatal error: File not found: 'pocrt.lib-section:Shared,rws'.
looks like a concatenation of the library and the linker pragmas.
In the moment no variant is working (no list displayed). I have tried several times (with pocrt.lib in the linker tab).
There should be different problems here...
The uncorrect layout of linker commands in the .drectve section is due to the 'handcrafted' form, and as I told you in my previous post it overwrites section data.
Now the OS, and related to it the compiler version, I haven't checked if the API's used in your sample are supported on W2K, have you?
What is the PellesC version you are using? Maybe is an older buggy one?
Compiling the sample with PellesC V8RC6 everything works ok on XP and 7.
On PellesC V8RC6 these errors are not show.