Posts

Showing posts with the label JNI

cannot pass objects of non-trivially-copyable type through '...'

Question: I have a string I am trying to print. when I used cout, it outputs perfectly but using printf leaves it mangled. Here is the code: int main ( int argc , char * argv [] ) { // Check to make sure there is a single argument if ( argc != 2 ) { cout << "usage: " << argv [ 0 ] << " <filename>\n" ; return 1 ; } // Grab the filename and remove the extension std :: string filename ( argv [ 1 ]); int lastindex = filename . find_last_of ( "." ); std :: string rawname = filename . substr ( 0 , lastindex ); cout << "rawname:" << rawname << endl ; printf ( "rawname: %s" , rawname ); } The cout gives me "rawname: file" The printf gives me "rawname: " and then a bunch of squiggly characters Sorry if this is a dumb question. I am doing my best to learn. Thank you...

how to fix error: unknown type name ‘namespace’

Question: #ifndef UNO_ACTION_ #define UNO_ACTION_ namespace Uno { namespace Game { class Game ; } } // namespace namespace Uno { namespace Action { using :: Uno :: Game :: Game ; class Action { public : virtual bool isDisposeable () = 0 ; virtual void takeAction ( Game * game ) = 0 ; virtual ~ Action () {} }; } } #endif I compile these code on ubutun 12.04 and it return to set of error: action . h : 4 : 1 : error : unknown type name ‘ namespace ’ action . h : 4 : 15 : error : expected ‘=’, ‘,’, ‘;’, ‘ asm ’ or ‘ __attribute__ ’ before ‘{’ token action . h : 8 : 1 : error : unknown type name ‘ namespace ’ action . h : 8 : 15 : error : expected ‘=’, ‘,’, ‘;’, ‘ asm ’ or ‘ __attribute__ ’ before ‘{’ token I don't know how to solve these errors. Solution:  It sounds like you're trying to compile your C++ code with a C compiler. Trying using g++ instead of gcc and giving ...