Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Bug with extern and namespaces

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
MrDoomMaster Posted - Jan 11 2007 : 10:08:47 PM
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.
5   L A T E S T    R E P L I E S    (Newest First)
MrDoomMaster Posted - May 31 2007 : 12:56:38 PM
Glad to be a contributor :)

Thanks for this one!
support Posted - May 31 2007 : 12:49:36 AM
fixed in build 1557
feline Posted - Jan 15 2007 : 12:06:35 PM
I am seeing the same effect here. Thank you for the clear description.

case=3752
MrDoomMaster Posted - Jan 12 2007 : 7:59:39 PM
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.
feline Posted - Jan 12 2007 : 3:16:40 PM
Which IDE are you using? So far I cannot reliably reproduce this using VS2005 and VA 1544.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000