I started working on a renderer in SDL last night and it was able to compile. I started working today and it’s been giving me this error:
/Users/kitchenmac/Desktop/Code/games/sdlRendering/libraries/sdl/SDL2/include/SDL_platform.h:182:8: error:
expected unqualified-id
extern "C" {
^
I’ve been trying to debug this for the past few hours but I can’t find anything online with a solution. I’m using a mac with OSX 10.14.3 and Apple LLVM version 10.0.0 (clang-1000.11.45.5)
This is my cmake file:
cmake_minimum_required(VERSION 2.6)
project(Renderer)
# Use our modified FindSDL2* modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${Renderer_SOURCE_DIR}/cmake")
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
# Bump up warning levels appropriately for clang, gcc & msvc
# Also set debug/optimization flags depending on the build type. IDE users choose this when
# selecting the build mode in their IDE
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++11 -g -fno-rtti")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /GR-")
endif()
endif()
# Look in the include and src subdirectory to find its CMakeLists.txt so we can build the executable
include_directories(include)
include_directories(${OPENGL_INCLUDE_DIR})
file(GLOB src "include/*.h" "src/*.cpp")
add_executable(Renderer ${src})
#eigen
set(eigen_DIR "${LIB_DIR}/eigen")
include_directories(${PROJECT_NAME} PRIVATE "${eigen_DIR}")
# glad
set(GLAD_DIR "${LIB_DIR}/glad")
add_library("glad" "${GLAD_DIR}/src/glad.c")
target_include_directories("glad" PRIVATE "${GLAD_DIR}/include")
target_include_directories(${PROJECT_NAME} PRIVATE "${GLAD_DIR}/include")
target_link_libraries(${PROJECT_NAME} "glad" "${CMAKE_DL_LIBS}")
# SDL2
add_subdirectory(libraries/sdl/SDL2)
include_directories(libraries/sdl/SDL2/include)
target_link_libraries(Renderer SDL2)
include_directories(libraries/SDL2_image-2.0.4)
file(GLOB SDL_IMAGE "libraries/SDL2_image-2.0.4/*.c")
add_library("SDL_image" ${SDL_IMAGE})
install(TARGETS Renderer RUNTIME DESTINATION ${Renderer_SOURCE_DIR}/bin)
file(COPY assets DESTINATION ${Renderer_SOURCE_DIR}/bin)
Here is the error message I get:
In file included from /Users/kitchenmac/Desktop/Code/games/sdlRendering/libraries/sdl/SDL2/include/SDL.h:31:
In file included from /Users/kitchenmac/Desktop/Code/games/sdlRendering/libraries/sdl/SDL2/include/SDL_assert.h:25:
In file included from /Users/kitchenmac/Desktop/Code/games/sdlRendering/libraries/sdl/SDL2/include/SDL_config.h:25:
/Users/kitchenmac/Desktop/Code/games/sdlRendering/libraries/sdl/SDL2/include/SDL_platform.h:182:8: error:
expected unqualified-id
extern "C" {
I think my computer updated over night which might have caused this problem. Any help would be appreciated!