Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_atomic.h creates compile errors in Visual Studio 2005 #329

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

SDL_atomic.h creates compile errors in Visual Studio 2005 #329

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

@SDLBugzilla SDLBugzilla commented Feb 10, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.3
Reported for operating system, platform: Windows (All), x86

Comments on the original bug report:

On 2011-01-21 01:52:11 +0000, John Wilson wrote:

1>c:\program files\microsoft visual studio 8\vc\include\ivec.h(233) : error C2733: second C linkage of overloaded function 'cmpeq' not allowed
1> c:\program files\microsoft visual studio 8\vc\include\ivec.h(233) : see declaration of 'cmpeq'

This is only the first of many errors regarding C linkage and overloaded functions. I traced it all back to SDL_atomic.h, where 'extern "C" {' is used, and while it is still in effect, 'intrin.h' is included, which leads to a long string of includes that end up at 'ivec.h'. This file uses function overloading and is not suitable for C linkage, thus I get lots of compiler errors in projects that use SDL.

On 2011-01-21 09:38:57 +0000, Sam Lantinga wrote:

I assume you're working on a C++ project?

Does it work to close the C linkage around the include?

e.g.
}
#include <intrin.h>
extern "C" {

On 2011-01-21 19:29:13 +0000, John Wilson wrote:

(In reply to comment # 1)

I assume you're working on a C++ project?

Does it work to close the C linkage around the include?

e.g.
}
#include <intrin.h>
extern "C" {

Yes, I'm using C++. I tried what you suggested, and it made it through the whole of SDL.h without errors. However, my project includes SDL_opengl.h right after that, which leads to winnt.h and these 2 errors:

1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(3112) : error C2733: second C linkage of overloaded function '_interlockedbittestandset' not allowed
1> c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(3109) : see declaration of '_interlockedbittestandset'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(3118) : error C2733: second C linkage of overloaded function '_interlockedbittestandreset' not allowed
1> c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(3115) : see declaration of '_interlockedbittestandreset'

I would say that intrin.h and winnt.h are conflicting somehow, as I don't get those errors if I comment out the SDL_atomic header.

I found that if I defined PREFIX it skips over that section of winnt.h and my project compiles successfully.

On 2011-01-21 23:23:32 +0000, Sam Lantinga wrote:

sigh

What happens if you just put these in a file by themselves?
#include <intrin.h>
#include <windows.h>
#include <winnt.h>

On 2011-01-21 23:27:28 +0000, Sam Lantinga wrote:

A little googling shows that this is a common problem. Hmm.

On 2011-01-21 23:28:55 +0000, Sam Lantinga wrote:

Are you using Visual Studio 2005?

On 2011-01-21 23:32:41 +0000, Sam Lantinga wrote:

Nevermind, it's in the subject. :)

On 2011-01-22 12:03:03 +0000, Sam Lantinga wrote:

Created attachment 556
Fix for Visual Studio 2005

On 2011-08-21 00:37:23 +0000, Ryan C. Gordon wrote:

Fixing up some bug report metadata.

--ryan.

On 2011-08-21 00:55:25 +0000, Ryan C. Gordon wrote:

Resolving bug: Sam committed the patch in Attachment # 556 as hg changeset 1e94e68525d5.

--ryan.

On 2014-08-12 15:02:55 +0000, wrote:

I have the same issue with VS 2008 and SDL 2.0.3.
Could you please look int this?

On 2014-08-12 15:04:40 +0000, wrote:

I'm trying to move from SDL 1.2.15 to SDL 2.0.3

On 2014-08-12 15:24:54 +0000, wrote:

Not sure if this error is related to "atomic" component, but anyway here is a part of the errors:

Error 12 error C2733: second C linkage of overloaded function 'cmpeq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 233
Error 14 error C2733: second C linkage of overloaded function 'cmpneq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 234
Error 20 error C2733: second C linkage of overloaded function 'unpack_low' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 240
Error 22 error C2733: second C linkage of overloaded function 'unpack_high' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 241
Error 24 error C2733: second C linkage of overloaded function 'cmpeq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 308
Error 26 error C2733: second C linkage of overloaded function 'cmpneq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 309
Error 28 error C2733: second C linkage of overloaded function 'unpack_low' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 311
Error 30 error C2733: second C linkage of overloaded function 'unpack_high' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 312
Error 33 error C2733: second C linkage of overloaded function 'cmpeq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 346
Error 35 error C2733: second C linkage of overloaded function 'cmpneq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 347
Error 37 error C2733: second C linkage of overloaded function 'unpack_low' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 349
Error 39 error C2733: second C linkage of overloaded function 'unpack_high' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 350
Error 41 error C2733: second C linkage of overloaded function 'operator *' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 422
Error 43 error C2733: second C linkage of overloaded function 'cmpeq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 425
Error 45 error C2733: second C linkage of overloaded function 'cmpneq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 426
Error 47 error C2733: second C linkage of overloaded function 'cmpgt' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 427
Error 49 error C2733: second C linkage of overloaded function 'cmplt' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 428
Error 51 error C2733: second C linkage of overloaded function 'cmple' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 429
Error 53 error C2733: second C linkage of overloaded function 'cmpge' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 430
Error 55 error C2733: second C linkage of overloaded function 'unpack_low' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 432
Error 57 error C2733: second C linkage of overloaded function 'unpack_high' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 433
Error 63 error C2733: second C linkage of overloaded function 'operator *' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 509
Error 65 error C2733: second C linkage of overloaded function 'cmpeq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 510
Error 67 error C2733: second C linkage of overloaded function 'cmpneq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 511
Error 69 error C2733: second C linkage of overloaded function 'sat_add' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 513
Error 71 error C2733: second C linkage of overloaded function 'sat_sub' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 514
Error 73 error C2733: second C linkage of overloaded function 'unpack_low' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 516
Error 75 error C2733: second C linkage of overloaded function 'unpack_high' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 517
Error 77 error C2733: second C linkage of overloaded function 'cmpeq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 544
Error 79 error C2733: second C linkage of overloaded function 'cmpneq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 545
Error 81 error C2733: second C linkage of overloaded function 'unpack_low' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 547
Error 83 error C2733: second C linkage of overloaded function 'unpack_high' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 548
Error 85 error C2733: second C linkage of overloaded function 'cmpeq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 617
Error 87 error C2733: second C linkage of overloaded function 'cmpneq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 618
Error 89 error C2733: second C linkage of overloaded function 'cmpgt' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 619
Error 91 error C2733: second C linkage of overloaded function 'cmplt' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 620
Error 93 error C2733: second C linkage of overloaded function 'cmple' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 621
Error 95 error C2733: second C linkage of overloaded function 'cmpge' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 622
Error 97 error C2733: second C linkage of overloaded function 'unpack_low' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 624
Error 99 error C2733: second C linkage of overloaded function 'unpack_high' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 625
Error 101 error C2733: second C linkage of overloaded function 'sat_add' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 627
Error 103 error C2733: second C linkage of overloaded function 'sat_sub' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 628
Error 105 error C2733: second C linkage of overloaded function 'cmpeq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 694
Error 107 error C2733: second C linkage of overloaded function 'cmpneq' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 695
Error 109 error C2733: second C linkage of overloaded function 'unpack_low' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 697
Error 111 error C2733: second C linkage of overloaded function 'unpack_high' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 698
Error 113 error C2733: second C linkage of overloaded function 'sat_add' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 700
Error 115 error C2733: second C linkage of overloaded function 'sat_sub' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 701
Error 118 error C2733: second C linkage of overloaded function 'pack_sat' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 704
Error 121 error C2733: second C linkage of overloaded function 'operator &' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 718
Error 123 error C2733: second C linkage of overloaded function 'operator |' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 718
Error 125 error C2733: second C linkage of overloaded function 'operator ^' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 718
Error 127 error C2733: second C linkage of overloaded function 'andnot' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 718
Error 129 error C2733: second C linkage of overloaded function 'operator &' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 719
Error 131 error C2733: second C linkage of overloaded function 'operator |' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 719
Error 133 error C2733: second C linkage of overloaded function 'operator ^' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 719
Error 135 error C2733: second C linkage of overloaded function 'andnot' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 719
Error 137 error C2733: second C linkage of overloaded function 'operator &' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 720
Error 139 error C2733: second C linkage of overloaded function 'operator |' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 720
Error 141 error C2733: second C linkage of overloaded function 'operator ^' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 720
Error 143 error C2733: second C linkage of overloaded function 'andnot' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 720
Error 145 error C2733: second C linkage of overloaded function 'operator &' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 721
Error 147 error C2733: second C linkage of overloaded function 'operator |' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 721
Error 149 error C2733: second C linkage of overloaded function 'operator ^' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 721
Error 151 error C2733: second C linkage of overloaded function 'andnot' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 721
Error 153 error C2733: second C linkage of overloaded function 'operator &' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 722
Error 155 error C2733: second C linkage of overloaded function 'operator |' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 722
Error 157 error C2733: second C linkage of overloaded function 'operator ^' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 722
Error 159 error C2733: second C linkage of overloaded function 'andnot' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 722
Error 161 error C2733: second C linkage of overloaded function 'operator &' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 723
Error 163 error C2733: second C linkage of overloaded function 'operator |' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 723
Error 165 error C2733: second C linkage of overloaded function 'operator ^' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 723
Error 167 error C2733: second C linkage of overloaded function 'andnot' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 723
Error 169 error C2733: second C linkage of overloaded function 'operator &' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 724
Error 171 error C2733: second C linkage of overloaded function 'operator |' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 724
Error 173 error C2733: second C linkage of overloaded function 'operator ^' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 724
Error 175 error C2733: second C linkage of overloaded function 'andnot' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 724
Error 177 error C2733: second C linkage of overloaded function 'operator &' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 725
Error 179 error C2733: second C linkage of overloaded function 'operator |' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 725
Error 181 error C2733: second C linkage of overloaded function 'operator ^' not allowed c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h 725

On 2014-08-17 20:48:12 +0000, Sam Lantinga wrote:

Can you try with the latest snapshot?
http://www.libsdl.org/tmp/SDL-2.0.zip

I'm building here with Visual Studio 2008 with no problems. I created a file called test.cpp with these lines in it, and it compiled just fine:

#include <windows.h>
#include "SDL_atomic.h"

If you're still having problems, can you post a code snippet that when compiled alone, shows the problem?

Thanks!

On 2015-05-26 13:29:37 +0000, Sam Lantinga wrote:

No response, I'm going to assume this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant