Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Bug with extern and namespaces
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MrDoomMaster
Tomato Guru

251 Posts

Posted - Jan 11 2007 :  10:08:47 PM  Show Profile  Reply with Quote
Suppose I have the following code in a header file:

#ifndef _BOBSGLOBAL_H_
#define _BOBSGLOBAL_H_

#include "Types.h"

namespace bob
{
	enum eGameMode
	{
		STORYMODE,
		WORLDBATTLE
	};

	extern s32				currentWeaponSlot;
	extern s32				currentRegion;
	extern eGameMode		gameMode;
}


#endif // _BOBSGLOBAL_H_



Now suppose I have the following in the corresponding CPP file:

namespace bob
{
	s32			currentWeaponSlot				= 0;
	s32			currentRegion					= 0;
	eGameMode	gameMode						;
}


Now inside of a completely different CPP file that includes the header file listed above, if I do:

bob::

I only get a member listing with enums, but not the externs. This seems to be a bug, since those variables are declared in the 'bob' namespace.

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jan 12 2007 :  3:16:40 PM  Show Profile  Reply with Quote
Which IDE are you using? So far I cannot reliably reproduce this using VS2005 and VA 1544.

zen is the art of being at one with the two'ness
Go to Top of Page

MrDoomMaster
Tomato Guru

251 Posts

Posted - Jan 12 2007 :  7:59:39 PM  Show Profile  Reply with Quote
I am using VS2005 build 1543

I found a worthy test case:

1) Create a file called Bob.h
2) Put the following code in it:

namespace bob
{
	enum myenum
	{
		ENUM1,
		ENUM2
	};

	extern int variable1;
	extern int variable2;
}


3) Now create another file called Bob.cpp
4) Paste the following code into the new file:

#include "bob.h"

namespace bob
{
	int variable1 = 0;
	int variable2 = 0;
}


5) Now both files have been created. Make sure they both are added to your VS2005 project and that you're using build 1543 of VAX. Don't even worry about a 'main.cpp' with any entry point functions. Only have these files.
6) From Bob.cpp, type the following on a new line at the very bottom of the file: bob::
7) Notice how in step 6 you get a member listing with the enums AND the extern variables.
8) Delete the code typed in at step 6 and now go to Bob.h and type the same thing: bob::
9) From step 8 you get another member listing. THIS time with the enums but NO extern variables.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jan 15 2007 :  12:06:35 PM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description.

case=3752

zen is the art of being at one with the two'ness
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - May 31 2007 :  12:49:36 AM  Show Profile  Reply with Quote
fixed in build 1557
Go to Top of Page

MrDoomMaster
Tomato Guru

251 Posts

Posted - May 31 2007 :  12:56:38 PM  Show Profile  Reply with Quote
Glad to be a contributor :)

Thanks for this one!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000