OOLua compile errors - c++

Code
#include <OOLua/oolua.h>
class foo
{
public:
int bar();
};
OOLUA_CLASS_NO_BASES(foo)//class has no bases
OOLUA_NO_TYPEDEFS
OOLUA_MEM_FUN_0(int,bar)
OOLUA_CLASS_END
Compiler output
main.cpp(21) : error C2061: syntax error : identifier 'bar'
main.cpp(22) : error C2143: syntax error : missing ';' before '}'
main.cpp(22) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
main.cpp(22) : warning C4183: 'OOLUA_MEM_FUN_0': missing return type; assumed to be a member function returning 'int'
Using
Visual Studio 2008
OOLua 1.2.1
(OOLua .lib has been built and linked to)
Links
http://code.google.com/p/oolua/
Question
How can it be fixed? The code segment is from the 'Cheat Sheet' of OOLua's google code website.
Solved -> but still has problems
OOLua link errors

I am sorry you are having problems with the library, there is a mailing list set up for problems such as you are seeing http://groups.google.com/group/oolua-user?pli=1
The problem is due to a typo in the cheat sheet where "OOLUA_MEM_FUN_0" should read "OOLUA_MEM_FUNC_0". Thank you for drawing attention to the matter I will correct this.
Liam

It is only by chance that I have seen your message here, I would encourage you to use the forms of communication which I have detailed to you. I will not only be able to help you yet also anybody else who has similar problems.
As with any link errors for any library please post an example which displays the errors and the error messages in their entirety, as I will be more equipped to help you.
Thank you
Liam

Related

Compiler error when running Simulink models from Visual Studio

I have compiled all subsystems of a big, complex, Simulink model into a series of dlls. All of them are working in Visual Studio except one. The one that is not working is the only one that requires the simstruc.h header file, and I get about 120 error messages when I try to compile them. Most of them are in simstruc.h, but also in subsequent includes, like sfcn_bridge.h for example. All of them look the same way:
error C2143: syntax error : missing ';' before '*' c:\matlabr2011b_x86\rtw\c\src\sfcn_bridge.h (37)
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\matlabr2011b_x86\rtw\c\src\sfcn_bridge.h (37)
.
error C2143: syntax error : missing ';' before '*' c:\matlabr2011b_x86\simulink\include\simstruc.h (2135)
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\matlabr2011b_x86\simulink\include\simstruc.h (2135)
The code in the line in above example looks like this:
sfcn_bridge.h (37):
SS_SimMode *simModePtr;
simstruc.h (2135):
SparseHeader* slvrJacobianMatrix;
I have been able to compile programs that include simstruc.h before, but suddenly it's not working. Can anyone point me in the right direction?
Check if any of your class declaration missing ";" at the end.
class AAA
{
}; <--- this one
Edit:
Try these tips as well.
Rebuild the project
Right Click on each cpp file and click "Compile" to identify infected files.
Check include paths. specially sub folders in simulink include directory.
Go to the declaration of SparseHeader struct and check if it get skipped by any #ifdefs or any preprocessor definitions.
If your code base is small, comment out half of it until you get a compilable code. This is not easy however.

Difference Between WINAPI in C and C++

I am reading data from driver. The driver came with examples on how to develop applications based on the driver. The examples were written few years back. They use WINAPI and C. Now I will use their some header files. They have data structures and various other stuffs defined.
I tried creating a WINAPI in C++ and tried to link to those files. But as explained here, in the last answer, I very much believe that the same is problem with my code.
Now, I can't do as suggested there. My programs are long and I can't mess header files. They are complicated.
My option is to create my project entirely in C (I hope, it solves).
First, I renamed the file .cpp t0 .c.
(I don't even know the difference between these two programming languages. Their difference made no difference so far.)
MAIN QUESTION
I used file IO using API and used following:
HANDLE myFile=CreateFile("filename.txt",FILE_APPEND_DATA,FILE_SHARE_WRITE,0,\
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
int BufferNo=sprintf(body,"%.5f %[3].5f %[3].5f %[3].5f %[3].5f %[3].5f %[3].5f \
%[3].5f %[3].5f \n",a1,a2,a3,a4,a5,a6,a7,a8,a9);
WriteFile(myFile,body,lstrlen(body),0,NULL);
CloseHandle(myFile);
Problem is it does not compile. Says errors like:
error C2275: 'HANDLE' : illegal use of this type as an expression
error C2146: syntax error : missing ';' before identifier 'myFile'
error C2065: 'myFile' : undeclared identifier
warning C4047: '=' : 'int' differs in levels of indirection from 'HANDLE'
error C2143: syntax error : missing ';' before 'type'
error C2065: 'myFile' : undeclared identifier
warning C4022: 'WriteFile' : pointer mismatch for actual parameter 1
error C2065: 'myFile' : undeclared identifier
warning C4022: 'CloseHandle' : pointer mismatch for actual parameter 1
These were not errors in C++ and they compiled, just did not link. How do I solve this.
Note, there is similar function I have used before this. Which is not detected as error.
HANDLE myFile=CreateFile("filename.txt",GENERIC_WRITE,FILE_SHARE_WRITE,0,\
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,0);
char* HeadingStr="a1(m) a2(m) a3(m) a4(m) a5(m) a6(m) a7(m)\
a8(m) a9(m)\n";
WriteFile(myFile,HeadingStr,lstrlen(HeadingStr),0,NULL);
CloseHandle(myFile);
This does not show any error. It is in same file and is before, in different function above errors. This is in WinMain and above is in WndProc function.
The Visual Studio compiler does not support C99, which is when inline declarations were added. You need to declare all of your variables at the beginning of your functions, or switch to a compiler that supports C99.

Qt QPainterpath.h errors

I am currently working on a Qt application with many #include files from the Qt library. The project is quite large and I have encountered a strange problem when building. The errors displayed are all inside the QPainterpath.h file, but has nothing to do with calls to it from my project. The errors all look like this:
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(397) : error C2143: syntax error : missing ';' before '::'
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(397) : error C2059: syntax error : '::'
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(398) : error C2143: syntax error : missing ';' before '{'
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(398) : error C2447: '{' : missing function header (old-style formal list?)
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(405) : warning C4003: not enough actual parameters for macro 'elementCount'
I encountered this once before and was able to solve it by moving some Qt #include statements called before other class headers below them. I can't seem to figure out what in particular is causing it this time though. Any thoughts would be great!
Thanks!
I've seen this happen when you forget to close a class definition with a semicolon. If you look at the output from the compiler, and see which file was compiled right before this error started, you may have your answer. Look for syntax errors with missing a ; or an extra } or a missing } at the end of the previously compiled file.
It could also be from a .h file listed above your #include <QPainter> call that has the errors.
Hope that helps.
I'm working with RyGuyFalcore and figured out why this is happening in our code, and nobody else is seeing it. The issue is that our legacy code was redefining the elementCount macro. Therefore, if we included that portion of our legacy code before we included the Qt code, the wrong macro was getting used :( Figured I would post this here to avoid any wild goose chase that others may run into if they hit a similar bug.

VS 2012 template errors

I've been using this code to marshal strings in C++/CLI for a while now. Recently I've updated to VS 2012 RC to try it out. I really liked the simple design, but none of my projects containing clix.h could be compiled. It worked great in 2010... What could be the problem? Thank you for your answers!
Here is compiler output:
Warning C4346:
'clix::detail::IsManagedString::Result'dependent name is
not a type.
Error C2988: unrecognizable template declaration/definition
Error C2059: syntax error : '<'
Error C2039: 'Result' : is not a member of '`global namespace''
Error C2143: syntax error : missing ';' before '}'
The code block errors are in:
typename detail::Select<detail::IsManagedString<SourceType>::Result>::Type<
typename detail::StringTypeSelecter<encoding>::Type,
System::String ^>::Result marshalString(SourceType string) {
// Pass on the call to our nifty template routines
return detail::StringMarshaler<
detail::IsManagedString<SourceType>::Result ? detail::CxxFromNet : detail::NetFromCxx
>::marshal<encoding, SourceType>(string);
}
An example, source file:
#include "clix.h"
int main()
{
}
Clix header file can be found on this link.
You could have just posted the issue on my blog, it's not abandoned or anything :)
I happen to have Visual Studio 2012 RC installed and fixed the issue. You can find a new version of the clix header at the location you linked.
Background: it appears Microsofts new compiler is a bit picky regarding typedefs in nested templates whose parent templates are specialized on integer types. In any case, I found a method that works in both Visual C++ 2010 and Visual C++ 2012 RC.

Compiliation errors on boost files

I'm getting a lot of errors compiling code using the boost libraries, mainly when I'm using Spirit namespace. The errors are syntax errors on boost files like:
boost/spirit/home/classic/dynamic/lazy.hpp(33) : error C2143: syntax error : missing ';' before '<'
or
boost/spirit/home/classic/dynamic/lazy.hpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
or
boost/spirit/home/classic/utility/grammar_def.hpp(104)
: error C2039: 'nil_t' : is not a
member of 'boost::phoenix'
I am migrating from Visual Studio 6 to Visual Studio 2008 Express and from one of the oldest versions of boost to the lastest.
I'd like to know what's the problem. I'm thinking the problem can't be in the boost library.
My guess, like Timi Geusch, is an errant #define.
I've never used VS, but if there is an option to see the code after it has been passed through the preprocessor, you might be able to figure out what causing the problem.
The problem was resolved just including phoenix1 the old version of phoenix.