c++ code...
c++ code...
i tried to include a c++ package to my sourcecode today,
and failed, gave me lots of undefined errors (can't show it up, cause i already deleted the files, maybe too fast... *argh*)
before including those files
i did a clean: make and make install, which successfully worked out!
it was even possible to compile the sample projects;
so my question:
is it possible to include c++ code
or is only C99 supported by the sdk/modded compiler
thanks in advance
lumo
and failed, gave me lots of undefined errors (can't show it up, cause i already deleted the files, maybe too fast... *argh*)
before including those files
i did a clean: make and make install, which successfully worked out!
it was even possible to compile the sample projects;
so my question:
is it possible to include c++ code
or is only C99 supported by the sdk/modded compiler
thanks in advance
lumo
-lstdc++
is this a standard lib or do i have to svn it somewhere?
(if not standard, where can i get it?)
my c++ code is with .cpp extension :)
thanks for your fast answer
edit:
edited my makefile-flags to:
lumo
is this a standard lib or do i have to svn it somewhere?
(if not standard, where can i get it?)
my c++ code is with .cpp extension :)
thanks for your fast answer
edit:
edited my makefile-flags to:
Code: Select all
LFLAGS = -L/usr/local/lib -lglut32 -lglu32 -llua -llualib -lopengl32 -lpng -lstdc++
CFLAGS = -I$(PSPSDK)/sdk/include -I$(PSPSDK)/include -Isrc
Code: Select all
dc++ -lkernel32
src/luasound.c:9:20: iostream: No such file or directory
src/luasound.c:10:18: memory: No such file or directory
In file included from src/luasound.c:12:
/usr/local/include/audiere.h:21:18: vector: No such file or directory
/usr/local/include/audiere.h:22:18: string: No such file or directory
/usr/local/include/audiere.h:30:4: #error Audiere requires C++
In file included from src/luasound.c:12:
/usr/local/include/audiere.h:61: error: parse error before "audiere"
/usr/local/include/audiere.h:61: error: syntax error before '{' token
/usr/local/include/audiere.h:84: error: syntax error before "void"
/usr/local/include/audiere.h:84: error: function `unref' is initialized like a v
ariable
/usr/local/include/audiere.h:85: error: parse error before '}' token
/usr/local/include/audiere.h:88: error: arse error before '<' token
/usr/local/include/audiere.h:93: error: ptr' undeclared here (not in a function
)
/usr/local/include/audiere.h:94: error: parse error before '}' token
/usr/local/include/audiere.h:96: error: parse error before '<' token
/usr/local/include/audiere.h: In function `RefPtr':
/usr/local/include/audiere.h:97: error: `m_ptr' undeclared (first use in this fu
nction)
/usr/local/include/audiere.h:97: error: (Each undeclared identifier is reported
only once
/usr/local/include/audiere.h:97: error: for each function it appears in.)
/usr/local/include/audiere.h: At top level:
/usr/local/include/audiere.h:101: error: parse error before '~' token
/usr/local/include/audiere.h:105: error: parse error before '}' token
/usr/local/include/audiere.h:113: error: redefinition of 'm_ptr'
/usr/local/include/audiere.h:104: error: previous definition of 'm_ptr' was here
/usr/local/include/audiere.h:114: error: parse error before "if"
/usr/local/include/audiere.h: In function `bool':
/usr/local/include/audiere.h:134: error: parse error before '{' token
/usr/local/include/audiere.h: At top level:
/usr/local/include/audiere.h:142: error: parse error before ':' token
/usr/local/include/audiere.h:151: error: parse error before '<' token
/usr/local/include/audiere.h: In function `unref':
/usr/local/include/audiere.h:170: error: `m_ref_count' undeclared (first use in
this function)
/usr/local/include/audiere.h:171: error: `delete' undeclared (first use in this
function)
/usr/local/include/audiere.h:171: error: parse error before "this"
/usr/local/include/audiere.h: At top level:
/usr/local/include/audiere.h:175: error: parse error before ':' token
/usr/local/include/audiere.h:188: error: parse error before "File"
/usr/local/include/audiere.h:210: error: syntax error before "int"
/usr/local/include/audiere.h:210: error: function `read' is initialized like a v
thats my aim... include a cpp header file...
--> changed the file to luasound.cpp
get some new errors now (which were working just fine before)
but i will fix that for sure :)
EDIT:
is there a way to include cpp to c without changing the c code to cpp?
would be hard work to change all the already done work to cpp
thanks for your help :)
--> changed the file to luasound.cpp
get some new errors now (which were working just fine before)
but i will fix that for sure :)
EDIT:
is there a way to include cpp to c without changing the c code to cpp?
would be hard work to change all the already done work to cpp
thanks for your help :)
The other way works: If you have some C code, you can include the functions and variables with 'extern "C"' in a C++ file from a header file. Using C++ from C functions is possible, too, but more difficult (wrapper functions etc. are needed, if you are using classes and objects, like iostream).LuMo wrote:is there a way to include cpp to c without changing the c code to cpp?
would be hard work to change all the already done work to cpp
But luasound.c looks like you are trying to use C++ in Lua Player. I've thought myself about converting it to C++, because the syntax is a bit easier (no need for "struct" in variable definitions, for (int i=.. etc.) and it catches some more errors at compile time. Perhaps you should ask this in the Lua Player forum, to hear some opinions.
well, i adapted the filenames, and changed the includes, modified some code to get rid of errors;
worked fine to to a point...
since i am only coding in c/cpp for some weeks now i do not understand why i get the following errors (screens full!)
thanks in advance
lumo
worked fine to to a point...
since i am only coding in c/cpp for some weeks now i do not understand why i get the following errors (screens full!)
so, actually i know what undefined reference means; BUT why do i get that? was working in c just fine (and nowhere in the code are those functions defined) so i guess its an include from the lua library? (please do not tell me that i have to convert that to cpp...)cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1a3
): undefined reference to `lua_remove(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1a6e
): undefined reference to `lua_remove(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1a83
): undefined reference to `luaL_error(lua_State*, char const*, ...)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1a9e
): undefined reference to `luaL_checkint(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1ab
): undefined reference to `luaL_checkint(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1b0
): undefined reference to `luaL_checkint(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1b2f
): undefined reference to `luaL_checkint(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1b5
): undefined reference to `luaL_checkint(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1b8
): more undefined references to `luaL_checkint(lua_State*, int)' follow
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1ca3
): undefined reference to `lua_gettop(lua_State*)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1cd1
): undefined reference to `luaL_error(lua_State*, char const*, ...)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1cf
): undefined reference to `lua_toboolean(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1d2
): undefined reference to `lua_settop(lua_State*, int)'
cygwin/Temp/cccDt85J.o:luagraphics.cpp:(.text+0x1d4
thanks in advance
lumo
hehe yeah, i know what you mean,
and thats even what i did...
i even included ALL psp-related includes to extern "C" afterwards
but, heh, still getting those errors...
and thats even what i did...
Code: Select all
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
but, heh, still getting those errors...
sure, the only thing i am trying, is to put luaplayer to c++
EDIT:
bugga i forgot the makefile
greets
lumo
PS: the link is in the text :)
EDIT:
bugga i forgot the makefile
greets
lumo
PS: the link is in the text :)
I can't reproduce your bugs, but when removing the lumo_graphics.cpp from the Makefile, which was not in your package, I get some errors for undefined sce-functions. The reason is that in emulator.cpp for example pspdisplay.h was not imported. This means, some functions are defined with C++ linkage, so it can't be found when included with extern "C". After including all headers, it compiles to an exe. Sometimes C++ is tricky :-)
well i am now at the point where only the sce functions are missing;
i have no clue which headerfile to include...
only those files do not seem to find the sce-functions:
maybe you could upload my modded files?
EDIT:
eg.: graphic.cpp cannot find "sceGuShadeModel"
although i tried both
#include <pspgu.h>
and
extern "C" {
#include <pspgu.h>
}
still says that this function is not available (but it is!)
TIA
lumo
i have no clue which headerfile to include...
only those files do not seem to find the sce-functions:
- luaysystem.cpp
graphic.cpp
maybe you could upload my modded files?
EDIT:
eg.: graphic.cpp cannot find "sceGuShadeModel"
although i tried both
#include <pspgu.h>
and
extern "C" {
#include <pspgu.h>
}
still says that this function is not available (but it is!)
TIA
lumo