Reputation: 335
How do I generate pure code (without runtime checks) in VC++ 2010 Express ? For example I removed Buffer Security Check ( set compile opt /GS-), but in my code I again saw these calls
call __security_init_cookie ... call _RTC_CheckEsp ... call _RTC_CheckEsp ...
How do I remove these calls?
Upvotes: 2
Views: 3707
Reputation: 18839
It appears that the Visual Studio IDE does not have the option to remove all the /RTC
command line switches in the UI. I don't think the "none"
option it offers is quite the same.
So instead what worked for me was to use empty XML tags in the .vcxproj file, which blasts away the incoming or default options, and lets you compile a library with no runtime libraries whatsoever:
.vcxproj :
<ItemDefinitionGroup>
<ClCompile>
<BufferSecurityCheck>false</BufferSecurityCheck>
<SDLCheck>false</SDLCheck>
<BasicRuntimeChecks /> <!-- ←⎯ here -->
</ClCompile>
<Link>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
</ItemDefinitionGroup>
Of course, note that this means you'll have to provide your own DLLMain
entry point.
Upvotes: 0
Reputation: 740
Disable /RTC compiler switch http://msdn.microsoft.com/en-us/library/8wtf2dfz.aspx
Upvotes: 3
Reputation: 340406
The MSVC docs indicate that __security_init_cookie
is called by the CRT runtime for "code compiled with /GS (Buffer Security Check) and in code that uses exception handling" (emphasis added). See http://msdn.microsoft.com/en-us/library/ms235362%28v=VS.100%29.aspx
I wouldn't be surprised if there's code in the runtime library itself that depends on the security cookie having been initialized, whether your code uses it or not (in other words, the runtime library code may have been compiled with /GS, and if so, it needs the cookie initialized whether or not your code does).
As for the _RTC_CheckEsp
call - that should be controlled by the /RTCs
or the /RTC1
option. Remove those options from your build and there should be no calls to _RTC_CheckEsp
.
Upvotes: 7