Small correction for the C++ / Visual C++ wiki entry
Posted: Thu Aug 05, 2010 2:25 am
http://wiki.osdev.org/C%2B%2B#Visual_C.2B.2B
In the Global Objects, Visual C++ section it lists the init tables needed by the visual C compiler. It then merges it into the .data section. This was correct for visual C++ 6, it now needs to be merged into the .rdata section (because the CRT area is no longer read/write for some reason or another), otherwise there is an annoying linker warning (disclaimer: I find any warning annoying).
Here is the warning issued by visual C++ 7 and above (to help with people searching if they are having this warning):
It needs to be this:
In the Global Objects, Visual C++ section it lists the init tables needed by the visual C compiler. It then merges it into the .data section. This was correct for visual C++ 6, it now needs to be merged into the .rdata section (because the CRT area is no longer read/write for some reason or another), otherwise there is an annoying linker warning (disclaimer: I find any warning annoying).
Here is the warning issued by visual C++ 7 and above (to help with people searching if they are having this warning):
So instead of this:warning LNK4254: section '.CRT' (40000040) merged into '.data' (C0000040) with different attributes
Code: Select all
// ... snip
#pragma data_seg()
#pragma comment(linker, "/merge:.CRT=.data") // works fine in visual c++ 6
Code: Select all
// ... snip
#pragma data_seg()
#pragma comment(linker, "/merge:.CRT=.rdata") // for visual C++ 7 and above