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.
Related
I tried to use the community version of IntelliJ IDEA for a proprietary scripting language similar to Java (and I don't do actual Java development for now) which generally works quite well regarding simple refactoring and type hinting.
Because of mainly two differences in the language (boolean is bool and the API calls don't expect java.lang.String types but API specific ones) each class file is contaminated with several errors, which make it useless to quickly find actual errors in that scripting language using IDEA's inspections.
Examples (shown error by IDEA in the comment):
bool boolTypeVariable = true; //cannot resolve symbol bool
if(boolTypeVariable) //Incompatibles types: required boolean, found bool
nlvm.lang.String str = "a String"; //Incompatibles types: required nlvm.lang.String, found java.lang.String
(Other errors arise when using !bool, bool && bool and so on)
Is it possible to ignore just these specific kind of inspections or preferably make IDEA to inspect these as desired with small modifications?
I'm aware that it's possible to define own languages for IntelliJ but I'm mostly targeting for some quick solution (which can be dirty, if it works for that case)
I would also accept a suggestion for another IDE that does supports type hinting, inspections and some basic refactoring when it's easily possible to achieve this there (I just choose IDEA community for that since I'm familiar with PyCharm).
If disable inspection intention action is not available it means the error is reported either by the parser (such syntax is not supported) or a validation that can not be disabled (e.g. the class bool that must be present in the classpath (i.e. in JDK or module libraries or the javac would report the error). To completely remove validation errors you can disable highlighting for the file.
I am using (for now) a trial version of Embarcadero C++ Builder XE2 Architect. I am working through migrating our current code from Borland C++ Builder 6.
There a some type libraries that I have been importing and installing into a package. So far the ones I have run into have imported just fine. However, I needed to import the OLE Automation 2.0 library. Upon doing this, I receive several errors, the first of which is mentioned in the title of this post.
The other libraries I have imported so far are: Crystal Reports ActiveX Designer Run Time Library 11.0 (craxdrt.dll) and Microsoft Jet and Replication Objects 2.6 Library (msjro.dll).
The following shows where the IDE says the problems are (file stdole_TLB.h):
typedef Stdole_tlb::IFontDisp IFontDisp;
typedef Stdole_tlb::IFontDisp *IFontDispPtr;
typedef Stdole_tlb::IPictureDisp IPictureDisp;
typedef Stdole_tlb::IPictureDisp *IPictureDispPtr;
The full parser context messages for those just show:
stdole_TLB.cpp(28): #include ..\9.0\Imports\stdole_TLB.h
stdole_TLB.h(56): namespace Stdole_tlb
I also receive another error message:
[BCC32 Error] stdole_TLB.h(254): E2029 'TDispWrapper<IDispatch>' must be a previously defined class or struct
Full parser context
stdole_TLB.cpp(28): #include ..\9.0\Imports\stdole_TLB.h
stdole_TLB.h(56): namespace Stdole_tlb
stdole_TLB.h(253): class IUnknown
That last one generates a lot of error messages so I think if that could be knocked out, most of the errors will go away.
Any help is much appreciated!
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 trying to compile some software I've been writing in Linux that uses some fancy new C++0x features on my Mac. I used MacPorts to install the gcc45 package, which gave me /opt/local/bin/g++-mp-4.5, however this compiler doesn't want to compile anything in <thread>. Eg I try to compile:
//test.cpp
#include <thread>
int main()
{
std::thread x;
return 0;
}
and get:
bash-3.2$ /opt/local/bin/g++-mp-4.5 -std=c++0x test.cpp
test.cpp: In function 'int main()':
test.cpp:5:2: error: 'thread' is not a member of 'std'
test.cpp:5:14: error: expected ';' before 'x'
A quick look in /opt/local/include/gcc45/c++/thread shows that the std::thread class is defined, but is guarded by the following:
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
Again, this works perfectly on my Ubuntu machine, so what's the proper way to enable the c++0x <thread> library under the MacPorts version of g++ 4.5 (g++-mp-4.5)? Failing that, is there anything I need to know (configure flags, etc.) before I go about compiling gcc 4.5 myself?
Update:
It doesn't look like the SO community knows much about this, so maybe it's time to go a little closer to the developers. Does anyone know of an official mailing list I could forward this question to? Are there any etiquette tips to help me get an answer?
Update 2:
I asked SO for another temporary solution here, and so I'm now just substituting the boost::thread libraries for the std ones. Unfortunately, there is no boost::future so this isn't quite a full solution yet. Any help would still be greatly appreciated.
Actually <thread> library doesn't work under Mac OS X because pthreads here don't have some functions with timeouts (e.g. pthread_mutex_timedlock()). Availability of this functions have to be checked using _POSIX_TIMEOUTS macro but it's defined to -1 in Mac OS X 10.4, 10.5 and 10.6 (I don't know what's about 10.7) and this functions are really absent in pthread.h.
The _POSIX_TIMEOUTS macro is checked during the configuration of libstdc++. If the check ends successfully _GLIBCXX_HAS_GTHREADS macro becomes defined. And <thread> contents become available with -std=c++0x.
libstdc++ really needs _POSIX_TIMEOUTS e.g. in std::timed_mutex class implementation (see <mutex> header).
To summarize, I think that <thread> would become available on Mac OS X when GCC's gthreads or libstdc++ will implement pthread_mutex_timedlock() (and others) emulation or when this functions will be implemented in Mac OS X.
Or maybe there would be a way in the future C++ standard to query for language features (e.g. this timed functions and classes) and it will be possible to build libstdc++ with this features disabled. However I'm not very familiar with the future standard and have doubts about that feature.
Update - gcc4.7 now allows compilation of on OS X: See here
I'm trying to do ioctl command through Mono framework, but I cant find what I'm looking for.
I'm trying to send command to a DVB card that has a kernel module. I hope someone can link or explain clearly how this can be done. Any example with Mono using kernel modules would be useful I guess.
Mono does not contain a wrapper for ioctl in Mono.Unix, because ioctl call parameters vary greatly and such a wrapper would be almost useless. You should declare a DllImport for each ioctl you need.
You probably don't need a helper library written in C, however, you may need it during development to extract actual values hidden behind different C preprocessor macros. For example, to expand C header:
#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
compile and execute this helper:
#include <linux/dvb/frontend.h>
#include <stdio.h>
int main()
{
printf("const int FE_GET_INFO = %d;\n", FE_GET_INFO);
return 0;
}
A short mono mailing list discussion on the topic.
ioctl isn't supported by Mono AFAIK. Too OS-specific and parameter list depends on actual request. You could try DLLImport
Interop with Native Libraries
You should write a wrapper library for your exact calls. Look at how Mono.Unix wraps syscalls (google codesearch for Mono.Unix Syscall.cs) to get the idea. Then create a wrapper for each specific ioctl command, which uses your own representation of the data.
As jitter said - you'll need to DLLImport the ioctl itself.
Check for my similar question, and later question on the subject. In this case I'm trying to wrap the Videl4Linux interface, that could be of interest for you.
I really suggest those readings.