Ok, so I want to do a simple thing, but it looks like the compiler doesn't like me doing it. Here's some example code (posting my real code would fill this up with too much clutter)
In my case I'm trying to assign values to a settings class by calling a function. To assign the values I need only 2 parameters, so I suppose I could use the operator[]. I was hoping to at least understand why anything other then assignment (including scoping variable) can't be done before getting to main. Or better yet, how to get a few lines to execute before entering main, without some weird "hack" like the nop assignment.Code:int SomeFunctionOrWithMoreTypingAMethodInAnObject() { // do other stuff return 0; } int main (...) { // do stuff return 0; } /* This stuff is presumably run before we enter main, * during the assignment and memory creation stage * (I think there's a better word for that thing I can't * seem to remember the name of 0.o) */ // This ~works~ but then I'll probably have a bunch of nop's everywhere int nop = SomeFunctionOrWithMoreTypingAMethodInAnObject(); // This give an error (on gcc 4.2.2 at least) { int nop = SomeFunctionOrWithMoreTypingAMethodInAnObject(); } // This also give an error (on gcc 4.2.2 at least) SomeFunctionOrWithMoreTypingAMethodInAnObject();



LinkBack URL
About LinkBacks



