I'm having real problems getting this to work. I've read all about extern variables etc and how they work etc. The problem is that when using an extern int for instance does the value of that int get changed on a global level or when you initialise it within a specific function?
I need the value to be a global value that is changeable and useable across the whole project and multiple files. I realise that I could just pass it as a function argument but it is just one int that I would like to keep global as it is used throughout the program and passing it as an argument just adds unnecessary complexity.
I've looked at system header files but I don't think they need the variable to keep its global value.
I need to have an int variable which I can put in a header file and include in multiple files in the same project (which by the way I am also having problems with even if I do use the method shown here : http://www.bobarcher.org/software/include/index.html). How would one go about doing this?
Edit : I've read things like http://www.doc.ic.ac.uk/lab/secondyear/cshort/docs/node17.html and still find when linking that I get multiple symbol errors. Surely the extern keyword lets the compiler / linker know that the symbol is going to appear in more than one object file?
Edit 2 : After playing around with my code I guess it will work fine if I just pass it as a function argument. Hopefully it won't add too much complexity.
I need the value to be a global value that is changeable and useable across the whole project and multiple files. I realise that I could just pass it as a function argument but it is just one int that I would like to keep global as it is used throughout the program and passing it as an argument just adds unnecessary complexity.
I've looked at system header files but I don't think they need the variable to keep its global value.
I need to have an int variable which I can put in a header file and include in multiple files in the same project (which by the way I am also having problems with even if I do use the method shown here : http://www.bobarcher.org/software/include/index.html). How would one go about doing this?
Edit : I've read things like http://www.doc.ic.ac.uk/lab/secondyear/cshort/docs/node17.html and still find when linking that I get multiple symbol errors. Surely the extern keyword lets the compiler / linker know that the symbol is going to appear in more than one object file?
Edit 2 : After playing around with my code I guess it will work fine if I just pass it as a function argument. Hopefully it won't add too much complexity.