Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: va!n on May 05, 2014

Title: VS2013 Express Win32 Project - Compilererror when using Win32 API calls
Post by: va!n on May 05, 2014
I am trying to use a Win32 project template to work with Visual Studio 2013 Express.
When using some Win32 API calls like "ZeroMemory()", "InitCommonControlsEx()" ... the project can't be compiled and i have no idea whats wrong with the project or settings. Any idea what's wrong and how to solve the problem? Thanks!

My VS2013 Win32 Project Template (12k ZIP) (http://www.secretly.de/public/Win32 - My Empty Template.zip)

Title: Re: VS2013 Express Win32 Project - Compilererror when using Win32 API calls
Post by: va!n on August 16, 2014
Thanks in advance for any help, to solve ths problem(s)...
Title: Re: VS2013 Express Win32 Project - Compilererror when using Win32 API calls
Post by: spitfire on August 16, 2014
Looks like the lib for memset is missing, but that only happens when I uncomment both ZeroMemory calls. Maybe some compiler optimization is changing the code? I dunno man sorry.
Title: Re: VS2013 Express Win32 Project - Compilererror when using Win32 API calls
Post by: Jim on August 17, 2014
Hi Va!n,

Well, in your linker options you have set /NODEFAULTLIB
That means no C runtime.  ZeroMemory is just an alias for memset which is a C runtime function.

Also, looks like you're trying to write tiny programs by using WinMainCRTStartup instead of WinMain as an entry point.  If you do that you can't use C runtime at all anyway.

If you want to call InitCommonControlsEx() then you need to add comctl32.lib to the linker dependencies in the linker options.  It's not one of the defaults.

Jim
Title: Re: VS2013 Express Win32 Project - Compilererror when using Win32 API calls
Post by: va!n on August 17, 2014
Hi Jim,

thanks for your hint. I changed the entry point to WinMain and changed the /NODEFAULTLIB option. Now i can compile the source without problems.

The Win32 API function ZeroMemory() can be found in the executeable as memset() - I dont know why, but it still works!  :cheers:
Title: Re: VS2013 Express Win32 Project - Compilererror when using Win32 API calls
Post by: Jim on August 17, 2014
ZeroMemory isn't a win32 api call, it's a macro that finally ends up as an invocation of memset.

Glad you got it working!

Jim
Title: Re: VS2013 Express Win32 Project - Compilererror when using Win32 API calls
Post by: Hotshot on August 17, 2014
Installing VS 2013 is pain in the ass to be honest and have you installed more bloody driver for it!
Title: Re: VS2013 Express Win32 Project - Compilererror when using Win32 API calls
Post by: rain_storm on August 23, 2014
You can use WinMainCRTStartup without using the NODEFAULTLIB switch. This will allow you to use the intrinsic functions ( such as memset ) without pulling in the entire CRT. But you will have to be extremely careful that the only CRT functions you use are intrinsics. This will also allow you to use a limited set of floating point functions.