IsDebuggerPresent() function is not declared in Visual Studion 2005 and lower
GoogleCodeExporter opened this issue · comments
What steps will reproduce the problem?
1. Create the simple test first_test.c:
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include "cmockery.h"
void main(void) {}
2. Put cmockery.h and cmockery.c to the same directory
3. Compile it: cl /I. first_test.c cmockery.c
What is the expected output? What do you see instead?
Visual Studio 2003:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
first_test.c
cmockery.c
Generating Code...
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
/out:first_test.exe
first_test.obj
cmockery.obj
cmockery.obj : error LNK2019: unresolved external symbol IsDebuggerPresent
referenced in function __run_test
first_test.exe : fatal error LNK1120: 1 unresolved externals
Visual Studio 2005:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for
80x86
Copyright (C) Microsoft Corporation. All rights reserved.
first_test.c
cmockery.c
Generating Code...
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/out:first_test.exe
first_test.obj
cmockery.obj
cmockery.obj : error LNK2019: unresolved external symbol _IsDebuggerPresent
refe
renced in function __run_test
first_test.exe : fatal error LNK1120: 1 unresolved externals
Visual Studio 2008:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
first_test.c
cmockery.c
Generating Code...
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
/out:first_test.exe
first_test.obj
cmockery.obj
What version of the product are you using? On what operating system?
- cmockery 0.1.2
- Visual Studio 2003, 2005 SP1, 2008
- Windows XP SP3
Please provide any additional information below.
Conclusion: Only starting from Visual Studio 2008 the function
IsDebuggerPresent() is declared in headers.
I use the following patch which explicitly declares the function
IsDebuggerPresent() for Visual Studio 2005 and lower:
--- a/cmockery.h Sat Dec 13 17:39:25 2008
+++ b/cmockery.h Sat Dec 13 19:07:44 2008
@@ -15,19 +15,6 @@
*/
#ifndef CMOCKERY_H_
#define CMOCKERY_H_
-
-#ifdef _WIN32
-#if _MSC_VER < 1500
-#ifdef __cplusplus
-extern "C" {
-#endif
-int __stdcall IsDebuggerPresent();
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif
-#endif
-
/*
* These headers or their equivalents should be included prior to including
* this header file.
Original issue reported on code.google.com by ade...@gmail.com
on 13 Dec 2008 at 7:41
Original comment by stewarta...@gmail.com
on 10 Apr 2009 at 8:37
- Changed state: Started
Original comment by stewarta...@gmail.com
on 10 Apr 2009 at 9:44
This will be integrated into cmockery release 0.1.3.
Original comment by stewarta...@gmail.com
on 7 Jul 2009 at 7:43
just add
#define _WIN32_WINNT 0x0400
before
#include <windows.h>
may be a better methord.
Original comment by gaoz...@gmail.com
on 25 Nov 2009 at 4:16
This issue was closed by revision c67374c35028.
Original comment by stewarta...@gmail.com
on 8 Aug 2012 at 5:16
- Changed state: Fixed