Skip to content

SDL_config.h and stddef.h conflict #1673

@SDLBugzilla

Description

@SDLBugzilla

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.0
Reported for operating system, platform: Windows (XP), x86

Comments on the original bug report:

On 2014-10-22 19:59:55 +0000, Stolz wrote:

It is not possible to compile this:

#include <SDL2/SDL.h>
int main() {
  return 0;
}

in Embarcadero Rad Studio XE2 under WinXP-SP3 (Borland C++ Compiler). The errors are as follows:

[BCC32 Error] _stddef.h(167): E2238 Multiple declaration for 'size_t'
[BCC32 Error] SDL_config.h(67): E2344 Earlier declaration of 'size_t'

The errors are gone in case I add #include <stddef.h> before including SDL.h. But it looks like as a dirty huck.

On 2015-02-19 04:10:26 +0000, Ryan C. Gordon wrote:

We do some tapdancing to not offer a typedef for size_t unless it's an unknown compiler, so the fix is usually just adding a new #if for it; how are you building this with Borland C++? With the CMake project files? I'm not sure why this is hitting this problem in SDL_config.h instead of, say, SDL_config_windows.h or SDL_config_minimal.h ...

--ryan.

On 2016-10-02 23:17:33 +0000, Stolz wrote:

The problem still exists. I try to build a simple lib based on one source file. The project structure is as follows:

library
├── CMakeLists.txt
├── library.cpp
├── SDL
│   └── include
│       └── SDL.h
│       └── ...
│   └── lib
│       └── x86
│           └── SDL.lib
│           └── SDLmain.lib

library.cpp:

#include <SDL.h>

void run() {
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_Quit();
}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.2)
project(library)

set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} SDL)

find_package(SDL REQUIRED)

set(SOURCES library.cpp)
add_library(${PROJECT_NAME} ${SOURCES})

target_include_directories(${PROJECT_NAME} PRIVATE ${SDL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE ${SDL_LIBRARY})

build:

mkdir build
cd build
cmake -G "Borland Makefiles" ../library
make

The problem:

Error E2238 C:\Program Files\Embarcadero\RAD Studio\9.0\include\windows\crtl\_stddef.h 167: Multiple declaration for 'size_t'
SDL_config.h 67: Earlier declaration of 'size_t'
*** 2 errors in Compile ***

The project library can only be build with including stddef.h before SDL.h:

#include <stddef.h>
#include <SDL.h>

Now it is OK.

I suppose this is not a correct behaviour.


CMake:version 3.5.1
OS:Windows XP SP3
Compiler:Embarcadero C++Builder XE2 Version 16.0.4504.48759

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions