Open astewartau opened 7 years ago
Is it possible to see what are the compile options? If there are "really" wrong I think it could cause this kind of error when requesting code completion.
Thanks for the reply. I am not precisely sure what you're asking for when you say compile options, but perhaps the answer lies within my full CMakeLists.txt file which I am using to generate a MinGW Makefile.
cmake_minimum_required(VERSION 3.0)
SET(CMAKE_C_COMPILER gcc)
SET(CMAKE_CXX_COMPILER g++)
project(game)
include_directories(include)
link_directories(lib/mingw)
file(GLOB GAME_SRC
"src/*.cpp"
)
add_executable(
game
${GAME_SRC}
)
set_target_properties(game
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Debug"
)
target_compile_features(game PRIVATE cxx_range_for)
set(GCC_COVERAGE_COMPILE_FLAGS "-DGLEW_STATIC")
target_link_libraries(game
libglew32.a
libopengl32.a
libsfml-main-d.a
libsfml-graphics-d.a
libsfml-audio-d.a
libsfml-system-d.a
libsfml-window-d.a
)
I am calling cmake via cmake -G "MinGW Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
, which also generates a compile_commands.json
file which contains the following:
[
{
"directory": "E:/Downloads/SFML-Game/build",
"command": "E:\\Development\\Tools\\MinGW\\bin\\g++.exe @CMakeFiles/game.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles\\game.dir\\src\\main.cpp.obj -c E:\\Downloads\\SFML-Game\\src\\main.cpp",
"file": "E:/Downloads/SFML-Game/src/main.cpp"
}
]
Finally, I simply build via mingw32-make
.
Can you show the output of running Clang on the command line?
cd E:/Downloads/SFML-Game/build
clang++ @CMakeFiles/game.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles\game.dir\src\main.cpp.obj -c E:\Downloads\SFML-Game\src\main.c
It's possible the response file is causing some issues.
Sure - it is actually a .cpp file though, not a .c file. I changed it to .cpp, but I'm not sure if I should redo this with some other parameter.
E:\Downloads\SFML-Game\build>clang++ @CMakeFiles/game.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles\game.dir\src\main.cpp.obj -c E:\Downloads\SFML-Game\src\main.cpp
E:\Downloads\SFML-Game\src\main.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^
Assertion failed: (t.isNull() || !t->isReferenceType()) && "Expressions can't have reference type", file D:\src\llvm_release_build_3.5.0\llvm\tools\clang\include\clang/AST/Expr.h, line 134
clang++.exe: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.5.0 (217039)
Target: i686-pc-windows-gnu
Thread model: posix
clang++.exe: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang++.exe: note: diagnostic msg: Error generating preprocessed source(s).
It looks like Clang does not like your environment.
You can try to inline the response file, update Clang.
Hi, thanks for that. I've updated to Clang 4.0, and I removed MSBuild from my PATH after realising that it could be confusing it.
The command clang++ @CMakeFiles/game.dir/includes_CXX.rsp -std=gnu++14 -o CMakeFiles\game.dir\src\main.cpp.obj -c E:\Downloads\SFML-Game\src\main.cpp
now runs error-free and produces an .obj file. I had to change it to gnu++14 as well, as I got errors about 'auto' when it was on gnu++11 (error: 'auto' return without trailing return type; deduced return types are a C++14 extension
).
Unfortunately, though - I'm still getting the Iron I/O task error in Emacs.
Auto-complete now works as expected only when I manually change my compile_commands.json file from this:
[
{
"directory": "E:/Development/SFML-Game/build",
"command": "E:\\Development\\MinGW\\bin\\g++.exe @CMakeFiles/game.dir/includes_CXX.rsp -std=gnu++11 -o CMakeFiles\\game.dir\\src\\main.cpp.obj -c E:\\Development\\SFML-Game\\src\\main.cpp",
"file": "E:/Development/SFML-Game/src/main.cpp"
}
]
To this:
[
{
"directory": "E:/Development/SFML-Game/build",
"command": "E:\\Development\\MinGW\\bin\\g++.exe -I E:/Development/Tools/SFML-Game/include -std=gnu++11 -o CMakeFiles\\game.dir\\src\\main.cpp.obj -c E:\\Development\\SFML-Game\\src\\main.cpp",
"file": "E:/Development/SFML-Game/src/main.cpp"
}
]
What I have done here is replaced @CMakeFiles/game.dir/includes_CXX.rsp
with the literal contents of the file it's referring to, which are -I E:/Development/Tools/SFML-Game/include
.
I'm stoked to have irony-mode working, but it's a pain having to change my .json file each time I build. Do you know what might be happening here, given this new information?
That's what I meant by:
You can try to inline the response file
I suspect the response file to be an issue, for example, irony-mode parses some compile options but does not handle response file. And for libclang, I'm not sure what is the issue.
What is the content of the response file?
Can you show the whole file?
Is it just this: -I E:\\Development\\SFML-Game\\include
?
Ah, I didn't realise that was what you meant by response file. The contents of the .rsp file are as follows (including the blank line):
-IE:/Development/SFML-Game/include
EDIT: I just tried changing the /
style to what you listed in your comment - it doesn't seem to affect the outcome.
Update: I found #338 and followed the suggestion of adding a .clang_complete
file in the root directory (/src) with the contents of the includes_CXX.rsp
file. I don't know why, but this has solved the problem.
This can be easily automated by performing a post-build copy and rename of the rsp file so that the .clang_complete
file is always up-to-date.
Would still be interested to know why this works, or if there is a better solution.
I am very new to Emacs (I come from Atom and love Emacs a lot so far) and today I am trying to set up auto-completion for C++. I noticed there is another similar issue open already, but since I am new, I'm not sure if this is the same issue.
I am using:
I have built a
compile_commands.json
file using CMake, which is located in ../build. My cpp file is in ../src. I believe I have set up the location of the json file correctly.After enabling company, I get the following error when typing into a cpp file:
When I
toggle-debug-on-error
, I get the following:My relevant .emacs init is as follows:
Any advice as to what is going on would be fantastic! 😃