We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2763

Summary: SDL_config.h and stddef.h conflict
Product: SDL Reporter: Stolz <r.bolgov>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.0   
Hardware: x86   
OS: Windows (XP)   

Description Stolz 2014-10-22 19:59:55 UTC
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.
Comment 1 Ryan C. Gordon 2015-02-19 04:10:26 UTC
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.
Comment 2 Stolz 2016-10-02 23:17:33 UTC
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