RE: [Dev-C++] Global variables (linking errors)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Santiago P. C. <San...@yd...> - 2002-04-18 17:36:39
|
Hi Daniel, Avoid the use of global variables!!! Define the variable in the "main file" and pass it through pointers/references to functions located in other code files. It will be better if you do the same in the "main file", let's say: define the variable inside the main function and pass it to functions as a pointer/reference, you'll never worry again about where the child function code is: in the same file or in another file. Again: avoid the use of global variables!!! Hope this helps! Regards, Santy PS: If I remember well there is something you can do with 'extern' reserved word, but this is something I do not use, maybe someone else can give you more help... Sorry -----Original Message----- From: Daniel Glenfield [mailto:sp...@ho...] Sent: Thursday, April 18, 2002 6:13 PM To: dev...@li... Subject: [Dev-C++] Global variables (linking errors) Help me out here would you? I have three C++ source files, each with its own header file. I want to have a global variable that all three source files can use. But when I put the variable into one of the header files I get Linker Errors, telling me the variable has already been defined in the first of my source code files. I think it's to do with the header files, but I'm not sure. Can anyone help? Daniel _________________________________________________________________ Join the world's largest e-mail service with MSN Hotmail. http://www.hotmail.com _______________________________________________ Dev-cpp-users mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/dev-cpp-users -------------------------------------------------------------------------------------- This message and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. No confidentiality or privilege is waived or lost by any wrong transmission. If you have received this message in error, please immediately destroy it and kindly notify the sender by reply email. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Opinions, conclusions and other information in this message that do not relate to the official business of Ydilo Advanced Voice Solutions, S.A. shall be understood as neither given nor endorsed by it. -------------------------------------------------------------------------------------- |