Author Topic: VS2013 Express Win32 Project - Compilererror when using Win32 API calls  (Read 2525 times)

0 Members and 1 Guest are viewing this topic.

Offline va!n

  • Pentium
  • *****
  • Posts: 1418
  • Karma: 109
    • View Profile
    • http://www.secretly.de
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)

« Last Edit: August 16, 2014 by va!n »
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1418
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Thanks in advance for any help, to solve ths problem(s)...
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline spitfire

  • Amiga 1200
  • ****
  • Posts: 275
  • Karma: 9
    • View Profile
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.
« Last Edit: August 16, 2014 by spitfire »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
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
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1418
  • Karma: 109
    • View Profile
    • http://www.secretly.de
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:
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
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
Challenge Trophies Won:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Installing VS 2013 is pain in the ass to be honest and have you installed more bloody driver for it!

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
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.

Challenge Trophies Won: