Hi Gents. My project has been rocketing along nicely for a few weeks now and I have tried to move as much non-orx related c++ variables and functions into code & header files.
I would now like to move things like orxOBJECT declarations into a header (functions too) but I receive errors. I noticed I also got errors for things like STL strings and had to use std::string in the header because including <string> isn't appropriate in a header.
Of course my #include
"orxPluginAPI.h" is in my main .cpp file and my header is included from here so I figure I need to do something like the following:
pstPlayer = orxObject_CreateFromConfig("Player");
//extern orxOBJECT *pstPlayer; ???
But I get an error:
syntax error : missing ';' before '*'
This is all due to my limited but growing knowledge of c++. I'm sure the answer is quite basic to seasoned programmers.
Hi! Nice to see you were able to move forward with your dev.
It's a bit late here and I'm a bit tired but I'm not sure what you exactly want to do.
So you're using orx's launcher then? If you're building a stand alone (with a main() and Init, Run, Exit callbacks) you should include "orx.h" instead. I personally find more flexible the standalone version but i have to admit it wasn't always the case, especially a couple of years ago when initializing orx wasn't so straightforward.
Well, if I'm reading correctly, your main.h has no knowledge of orx whatsoever.
You need to include orx.h/orxPluginAPI.h in it so that orxOBJECT will be defined. Then in your main.cpp you simply have to include "main.h" instead of any orx headers.
Maybe that wasn't the answer you expected, but as I said, I'm a bit tired and I might have missed the obvious.
* Adding orxPluginAPI.h to main.h gives an "already defined error in main.cpp"
* Removing it from main.cpp gives an "already defined error in ***.obj"
But really... I suppose I do have to convert to a standalone project from the launcher eventually anyway. So perhaps I should work on that first and come back to this after.
But before I do, is it right to say that you can't really split up orx objects and functions into headers with the launcher project include?
But anyway, the launcher option was only meant for adding new plugins or for prototyping rapidly something within a single .obj.
As for your errors, did you do a rebuild to make sure no old object file was used for linking?
Converting to a stand alone should take you less than 5 mins. Your init callback stay the same, the run and exit ones can be empty.
Then you simply have to add a main function and call orx_Execute() from there. (If you're using a WinMain function for a windows console-less app, there's a orx_WinExecute() that can be used instead). Last step, convert your project to output an exe instead of a library, include "orx.h" instead of "orxPluginAPI.h" and that should be it.
As for splitting up into headers, what I mean is, declaring all my global orxOBJECT variables in the header, and placing all my function definitions into a header.
But I won't worry about that for now. I think converting to a standalone project is my first step. Everything might fall into place after that.
Very much appreciate your advice as always.
Let me know if you have any trouble with the conversion.
Glad to be of any help.
I'm glad it worked (and that I didn't forget any steps! ).
You'll see, it'll be much more flexible this way, especially if you want multiplatform support.