New version of cppcheck found two major code smells named "syntax error" in following old lines of code:
System::Reflection::Assembly^ Foo(Object^ /* obj */, System::ResolveEventArgs^ args)
{...}
and
catch (System::Exception^ /*e*/)
Errortext:
Cppcheck cannot tokenize the code correctly.
Any idea how to fix them? Is something wrong with the C++/CLI syntax?
It looks like a false positive for me, as the code compiles and works for a long time.
Any idea how to fix them?
There is nothing you can do. C++/CLI is a dialect of C++, it is not standard C++. cppcheck works only with standard C or C++, so it will fail to understand C++/CLI code and thus give you the diagnostic you see. You'll need to exclude the source files that use C++/CLI code from your cppcheck check to avoid these errors.
Related
Can any one help me in figuring out what compilers and interpreters are? And what their difference is ? Appreciate it if explained for Java beginner as I am one.
Basically (very basically), a compiler build your program. It translates your java code into something the computer understands. An interpreter runs your program.
Both can catch errors but they are different types. Compilation errors can be syntax, semantic or logical errors. On the other hand, errors from your interpreter are only known once you run the program.
For example, if you have an array that contains 3 fruits like this:
String[] fruits = ["apple", "banana", "strawberry"];
And you try this:
System.out.println(fruits[4]);
The compiler won't get the error, because there are no syntax errors (everything seems fine at compile-time) but once you run the program, you'll get an IndexOutOfBoundsException which is a RuntimeException caught by the interpreter.
Error BC31030 Conditional compilation constant '; ^^ ^^ EXCLUDE_CODEGEN' is not valid: Identifier expected. GpsHost C:\Projects\GpsTrackSolution\GpsHost\vbc 1 N/A
I am getting the above error when I try and build a VB.NET win forms app. I refactored it a little, updated to framework 4.7.2 and now I am getting this.
There is NO reference in ANY vbproj for that string of characters, either partial or full. I've done a find in file contents across the entire solution and cannot find that anywhere. Almost at my wit's end as to what could be doing this.
This was unrelated to VB, it was actually due to Orleans code generation trying to insert constants. Orleans isn't really designed to work with VB, so I switched to runtime codegen, instead of build time, and it worked.
I don't get an error for this obviously erroneous code sample. Instead, qt creator mark var as unused variable. Is it possible to fix this strange behavior? I want semantic checking working.
Update:
I've been talking about on the fly semantic checking. Most IDE's analyse code as you type, and highlite errors. Qt Creator seemd to do some code analisis on the fly (because syntax highliting shows differently types, virtual functions and other things), but it doesn't hightlte errors at all.
The code model used by Qt Creator is pretty good but is not based on a complete abstract syntax tree for each compilation unit. Some information about it is provided in this Qt blog post:
http://blog.qt.digia.com/2011/10/19/qt-creator-and-clang/
AFAIK, the current code model allows Qt Creator to do semantic highlighting, refactoring, displaying type hierarchies etc. but does not allow a complete on-the fly check for potential compile errors (like yours). Since the syntax of your code is correct, Qt Creator does not show an error.
Very strange behavior. I tried to compile such code:
#include <iostream>
using namespace std;
int main()
{
UndefinedType val;
cout<<"Test"<<endl;
return 0;
}
On My Qt 4.8.1, 4.8.3 with MinGW on Windows7, in QtCreator 2.5.2, but in every case got error:
main.cpp: In function 'int main()':
main.cpp:7:5: error: 'UndefinedType' was not declared in this scope
main.cpp:7:19: error: expected ';' before 'val'
Please, provide more information about your build environment.
I have an grammar for a template language.
I created this for Antlr 3.2 and CSharp2 target and have it working.
Now I try to change to antlr 3.4 and CSharp3 target (have tried CSharp2 also) and I get a strange error in the Parser in a synpred function.
Several variable declarations are missing the variable name:
IToken = default(IToken)
Some also have th wrong type
void = default(void);
should be
AstParserRuleReturnScope<CommonTree, IToken> = default(AstParserRuleReturnScope<CommonTree, IToken>);
Have any one seen this before and what could be causing this.
The grammar is the same that was working before.
Unfortunately I cannot share the grammar and I have not had time to create a test grammar that causes the same error.
I can of course fix the errors manually and the code works but it's a bit tiresome to have to go through the code after generation fixing them.
I was able to resolve this problem by using the native .NET version of the ANTLR code generation tool (Antlr3.exe) instead of the Java version. Specifically, antlr-dotnet-tool-3.4.1.9004.7z worked for me, whereas antlr-3.4-complete-no-antlrv2.jar did not.
I'm new to programming in Objective-C, though I do have some experience in Python. I wrote this (what I thought would be simple) program:
#include <stdio.h>
int main(){
printf("hello world\n");
return 0;
}
But when I click run in Xcode it gives me this error:
Command /Developer/usr/bin/clang failed with exit code 1
I don't know what I did wrong and was hoping someone could help. It executes from the command line but not from Xcode.
Like other commenters here, I can't see any direct problem with your code, so maybe you could get it to work if you start from a clean project template.
In Xcode, choose New Project, type Command line tool
You can select either straight C or Objective-C. The latter will give you an autorelease pool that you don't need for a Hello World program, but it doesn't harm, either.
Then type your code (printf("Your text\n")) into the main function and compile.
It should work.