I'm getting strange outputs when I compile my *.proto file using the protoc compiler.
The *.pb.h and *.pb.cc files compile just fine, but the *.pb.h is riddled with syntax errors:
inline specifier allowed on function declarations only
expected a ')'
'struct': missing tag name
And so on...
I'm not sure how to resolve this problem. If there was something wrong with my *.proto file, I would get a compilation error I think? How do I begin debugging this?
Related
I'm running clang-tidy on a header file header.h. However as some of the warning outputs, it's outputting system headers:
.../include/c++/8/bits/std_abs.h:46:8: error: expected identifier or '(' [clang-diagnostic-error]
extern "C++"
../include/c++/8/cctype:62:1: error: unknown type name 'namespace' [clang-diagnostic-error]
namespace std
../include/c++/8/cctype:62:14: error: expected ';' after top level declarator [clang-diagnostic-error]
namespace std
..
etc
The problem: I don't want to see the warnings for anything other than the source file I'm scanning, for either a source file or header file.
I've tried implementing the fix here (What is the correct way of providing header-filter for clang-tidy in Cmake?) using --header-filter but it didnt work. I added the path to the header file that I was scanning in the regex, but I was still seeing the system header warnings.
For clang-tidy to work your code needs to be compile-able by the clang backend to generate an AST. This is apparently not the case since clang-diagnostic-error is basically a compilation error.
The problem is you are including headers that cannot be compiled by clang, there is no way to filter that out.
Note: This is done in RHEL 7.2 with clang 8.0.1.
I'm running the command
clang-tidy test.C -- -I/path/to/header.h
and I get the following error:
1 error generated.
Error while processing test.C.
test.C:28:10: error: 'header.h' file not found [clang-diagnostic-error]
#include "header.h"
^
Found compiler error(s).
When I build using g++, it works fine. The above include is the first include statement of the file, and there's some more after it. The file structure is complicated, so it'd be difficult to show where the files are located. I thought the -I argument would find the header, but it doesn't. So, how do I get clang-tidy to find those headers?
Clang tools usually need a compilation database : the compile_commands.json.
It provides information required to build your cpp units (g.e the include directories).
You can generate this file from Make, CMake, etc. by using some external tools.
https://github.com/rizsotto/Bear is one of them.
I'm trying to use gSoap2.8 with VS2010 C++ project
I declared a pre-build event
wsdl2h.exe -o test.h "test.wsdl"
then it says
error C1083: Cannot open type library file:<path>\stlvector.h: Error loading type library/DLL. <path>\test.h
So I used -s to get rid of that as follows
wsdl2h.exe -s -o .\test.h "test.wsdl"
but then it say
error : #import: Cannot open file "soap12.h" for reading
How can I get rid of this?
The "Error loading type library/DLL" error is from the Visual C++ compiler. That would be caused by an include statement like the following in one of your own files:
#include test.h
To prevent this, just omit that include statement. The .h file that's generated by wsdl2h is only meant to be used by the soapcpp2 program. It's not supposed to be included in your project.
This answer is supported by the following statement from gSOAP's README.txt file:
Do not include the wsdl2h-generated 'calc.h' header file directly into your code (the declarations are replicated in the generated code).
The 'calc.h' file to which that statement refers is a sample file, which in your case corresponds to 'test.h'.
So, my question is how to fix some error in header file, to run program normally? For example I use c++ builder 2010 and when winuser.h file is included, the program always get error like this
Checking project dependencies...
Compiling Project7.cbproj (Debug
configuration) [BCC32 Error]
winuser.h(47): E2257 , expected Full
parser context
File6.cpp(4): #include c:\program files (x86)\embarcadero\rad
studio\7.0\include\winuser.h [BCC32
Error] winuser.h(48): E2257 , expected
Full parser context
i try to replace that file with original from default installation, but that still get same error, how to fix that?
The error is almost certainly caused by whatever code appears before line 4 of File6.cpp. Most likely that is another header file, in which case it is likely that the code therein is malformed - a missing semicolon or brace for example.
The quickest way to verify that winuser.h is not the issue is to change the order of inclusion so that winuser.h is included first.
Another possibility is that something in winuser.h is dependent on some other header not previously included or directly included in winuser.h. Most Win32 API headers are included by windows.h, and it is generally advisable to include windows,h rather than either of its children.
The message is hard to read but the actual error is "E2257 , expected" (coma expected)
From the RAD studio documentation:
A comma was expected in a list of declarations, initializations, or parameters.
This problem is often caused by a missing syntax element earlier in the file
or one of its included headers.
The error message give you the line where it happened and you should probably look before that. There is probably some '}', ')' or ';' or other syntaxic closer missing in your code just before the error (likely before inclusion of the header file in your code). Full error message (you truncated it) or actual code would make it easier to spot.
It is also possible, even if unlikely, that the error is in one of the headers included in winuser.h.
So the other day I went to compile a VC++ project I am working on and all of a sudden I get errors in almost all of my files saying:
new.h: error C2039: 'set_new_handler' : is not a member of 'std
new.h: error C2039: 'set_new_handelr' : symbol cannot be used in a using-declaration
"new.h" and 'set_new_handler' are not being used in any of my files, so I have no idea how or why these errors are suddenly appearing since they relate to a windows/VS library file.
Would anyone know what I can do to clear this error and compile my code again?
UPDATE After examining the files being included upon compilation, some files are including and some are . The problem is that is being included in afxwin.h and is being included in a third-party library. I honestly have no idea what to do with this problem...no other developers that have played with this code are running into this problem, may it be a settings problem? I am not using precompiled headers.
If I were to hazard a guess, I would say that <new.h> declares set_new_handler in the global namespace and <new> declares it within the std namespace. Some code is including <new.h> and expecting it to act as if it had included <new>. I would suspect either some 3rd party library/header or a precompiled header as suggested by Evan.
You can narrow down the culprit using either /showIncludes or pre-processing a source code file (using /E) and examining the output. I usually use the latter and look at the #line directives in the output file to figure out the include chain.
Good luck.