dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: error C4013: 'InitializeSRWLock' undefined; assuming extern returning int

  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,489

    error C4013: 'InitializeSRWLock' undefined; assuming extern returning int

    Firstly, I'm seeing this error when I try to compile a 3rd-party library. I see it with other function calls too - such as AcquireSRWLockExclusive() / TryAcquireSRWLockExclusive() / ReleaseSRWLockExclusive() and a few others. According to MSDN I should be able to fix this by #including <windows.h> or maybe <synchapi.h>

    I've tried #including both - and yet I still get the error...

    Secondly - this is VS2015 (Community Edition) but whenever I've compiled things in previous versions of MSVC, I've a feeling this was previously a warning. I've checked the project's Properties but warnings aren't set up to be treatable as errors. So might there be something in a header file somewhere which would over-ride the project setting (and thereby cause warnings to get treated as errors) ?
    "A problem well stated is a problem half solved. - Charles F. Kettering

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,414

    Re: error C4013: 'InitializeSRWLock' undefined; assuming extern returning int

    Why the old VS2015 community and not the current VS2017 Community???

    Do you have the macros WINVER and _WIN32_WINNT set correctly so that the compiler knows for what OS you are building?

    See https://msdn.microsoft.com/en-us/library/6sehtctf.aspx

    For user code, I've only seen C4013 as a level 3 warning - not as an error. I've only come across C4013 as an error when compiling drivers.

    What and how are you compiling?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.8.4)

  3. #3
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,489

    Re: error C4013: 'InitializeSRWLock' undefined; assuming extern returning int

    Quote Originally Posted by 2kaud View Post
    Why the old VS2015 community and not the current VS2017 Community???

    Do you have the macros WINVER and _WIN32_WINNT set correctly so that the compiler knows for what OS you are building?

    [...]

    What and how are you compiling?
    Hi 2kaud - I'm building an open-source (cross-platform) library called Glib. Many years ago I'd previously built it with VS2005 (which built okay) and I'm now trying it on a machine which happens to have VS2015 installed.

    You were right about _WIN32_WINNT. I'm building on Windows 7 so if I specifically set _WIN32_WINNT to 0x0601 the library now builds. However, I'm a bit puzzled... I can't find any other project where I've needed to set this myself. Have I just been lucky up to now?
    "A problem well stated is a problem half solved. - Charles F. Kettering

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)