RE: [Dev-C++] Demystifying namespace
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: P.D. v. Z. <pd...@xs...> - 2003-12-18 07:41:32
|
You shouldn't use #defines. #defines are cross-everything, they don't care
about scope, namespaces, functions, whatever. It's just a simple global
search&replace operation performed by the preprocessor. If you want your
namespace code to work, change it to something like:
namespace foo{
const std::string file = __func__;
const size_t line = __LINE__;
}
Note that I didn't test this though, but it should work (and didn't you mean
__FILE__ instead of __func__ there?)
Regards,
Paul
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Maya
Sent: Thursday, December 18, 2003 7:49 AM
To: C/C++ Programmers; Dev - C++
Subject: [Dev-C++] Demystifying namespace
I have a little bit of a problem with 'namespace'. Here is my problem:
namespace foo{
#define file __func__
#define line __LINE__
enum error_t {one, two, three};
}
namespace foo{
class loo{
public:
loo(){
std::string f = foo::file;
size_t l = foo::line;
std::cout << "file: " << f << " line: " << l << std::endl;
std::cout << foo::one << foo::two << foo::three << std::endl;
}
};
}
These std::cout's give me a parse error, what am I doing wrong?
--
FYI
http://www.astro.umd.edu/~marshall/abbrev.html
E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html
* You cannot exercise your power to a point of humiliation.
- Jean Chretien
* The media's the most powerful entity on earth. They have the
power to make the innocent guilty and to make the guilty
innocent, and that's power.
- Malcom X
* "Innocent until proven guilty", no... not in Canada!!
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|