Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

C++ Enums


  • Please log in to reply
3 replies to this topic

#1 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:12 PM

Posted 19 February 2009 - 09:49 PM

Hello :thumbsup:

Worked with C for quite some time... but I used to have a simple WORD or DWORD type and pepper my code with #define s.

At some point it was suggested I replace these items with ENUM types, in order to keep things inside of my namespace.

Here's my problem. The compiler doesn't want to see my enum type. Example:

FileA:
struct OPTION_STRUCT
{
	static std::vector<CRITERION_STRUCT *> regexes;
	static CRITERION_STRUCT *logical;
	static BOOL showall;
	static BOOL debug;
	static BOOL fullPath;
	static std::basic_string<TCHAR> display;
	static enum
	{
		SORT_TYPE_NONE = 0,
		SORT_TYPE_TYPE,
		SORT_TYPE_SIZE,
		SORT_TYPE_DATE,
		SORT_TYPE_NAME,
		SORT_TYPE_TYPE_DESCENDING,
		SORT_TYPE_SIZE_DESCENDING,
		SORT_TYPE_DATE_DESCENDING,
		SORT_TYPE_NAME_DESCENDING
	} sortMethod[5];
	static enum
	{
		ENCODING_TYPE_UTF8,
		ENCODING_TYPE_UTF16,
		ENCODING_TYPE_ACP,
		ENCODING_TYPE_OEM
	} encoding;
};

File B:
void defaults(OPTION_STRUCT *optionsArg)
{
	optionsArg->debug = FALSE;
	optionsArg->display = _T("#f");
	optionsArg->encoding = ENCODING_TYPE_UTF8; //ERROR UNDEFINED
	optionsArg->fullPath = FALSE;
	optionsArg->logical = NULL;
	optionsArg->regexes.clear();
	optionsArg->showall = FALSE;
	optionsArg->sortMethod[0] = SORT_TYPE_NONE; //ERROR UNDEFINED
	optionsArg->sortMethod[1] = SORT_TYPE_NONE; //ERROR UNDEFINED
}

Does anyone know what I'm bleeping up here?

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:05:12 PM

Posted 19 February 2009 - 10:10 PM

What are the errors being thrown?

#3 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer

  • Topic Starter

  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:12 PM

Posted 19 February 2009 - 10:14 PM

1>c:\users\billy\documents\programming\pevfind\pevfind\consoleparser.cpp(12) : error C2065: 'ENCODING_TYPE_UTF8' : undeclared identifier
1>c:\users\billy\documents\programming\pevfind\pevfind\consoleparser.cpp(17) : error C2065: 'SORT_TYPE_NONE' : undeclared identifier
1>c:\users\billy\documents\programming\pevfind\pevfind\consoleparser.cpp(18) : error C2065: 'SORT_TYPE_NONE' : undeclared identifier

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#4 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer

  • Topic Starter

  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:12 PM

Posted 19 February 2009 - 10:43 PM

Doh! Fixed it:

optionsArg->debug = FALSE;
	optionsArg->display = _T("#f");
	optionsArg->encoding = OPTION_STRUCT::ENCODING_TYPE_UTF8;
	optionsArg->fullPath = FALSE;
	optionsArg->logical = NULL;
	optionsArg->regexes.clear();
	optionsArg->showall = FALSE;
	optionsArg->sortMethod[0] = OPTION_STRUCT::SORT_TYPE_NONE;
	optionsArg->sortMethod[1] = OPTION_STRUCT::SORT_TYPE_NONE;

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users