Jump to content
  • Advertisement
Sign in to follow this  
Ey-Lord

Macro __FILE__ under VC .

This topic is 4319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello guys, i got a little problem . I use the macro __FILE__ , with vc 2003 , and i build either in debug or in release . In release, it's fine, i got my string "./xxx.cpp", but in debug i got the FULL path, like "c://....//..//xxx.cpp" , i want to have ONLY the short relativ path . I heard i can have the full path with the command line /FC , but i want the oposite, i want the short path ...or i want to remove the /FC thing, but i dont find it ... Any ideas ?.

Share this post


Link to post
Share on other sites
Advertisement
It is relatively simply to chop the "long" string into the "short" string at runtime before you print the string. As far as I know, that is your best (maybe only) option.

Share this post


Link to post
Share on other sites
I'm quite sure if taht it's only a compiler choice to set full path in debug, i may find how to disaable this ... and the problem whith cutting it is that it would require some macro related to VC ...kinda "hack" to me ...

Share this post


Link to post
Share on other sites
Oh, it's definately a "compiler's choice" kind of thing. The macro is standard but its exactly implemention is not. I meant, however, that you could trim the filename from within whatever function you are passing the macro to. For example, if you have an assert macro:


#define MY_ASSERT(c) if(!(c)) { CallAssertHandler(__FILE__); }

void CallAssertHandler(const char *file)
{
const char *p = file;
const char *f = file;

while(*p != 0)
{
if(*p == '\\' || *p == '/')
f = ++p;
else
++p;
}

// Use f...
}


(Code written quickly just now, may contain bugs, use at your own risk, void where prohibited, et cetera).

Share this post


Link to post
Share on other sites
Yup i know i can extract the string inside my function, but i want to avoid that, and keep the code clean and portable .

For Msdn, i already looked there :

http://msdn2.microsoft.com/en-us/library/027c4t2s.aspx

But i can't find the c++/advanced/use full path or something they are naming O_o


And the /FC - just set a warning saying taht the "-" is ignored :/

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Is this really a problem? Nobody but you and the other developers or testers (if any) will ever see the debug build, right?

Share this post


Link to post
Share on other sites
Right, but i want this to be portable, so it must compile smoothly under other compiler than VS, moreover, the xml file isnt displayed under I.E, it seems not to like the full path for a reason i dont get now .

And i'm 95% sure this can be solved by setting my compiler properly .

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Ey-Lord
Right, but i want this to be portable, so it must compile smoothly under other compiler than VS...


Right well I think you may have to use the preprocesser and see if _MSC_VER is defined and work on from there. What you are asking for is platform specific; as mentioned earlier "The macro is standard but its exactly implemention is not"

Share this post


Link to post
Share on other sites
Yup i may gop that way , even if i odont like it much .

Another thing i noticed, under FireFox, my XMl document ( turned in html with an xsl doc ) is displayed as it should be [ reminder : it bugs under IE ] when the fullpath is set ... i dunno why it doesnt work on I.E, the only change from fullpath vs short path is the name of the file ... those input are giving an error msg under I.E :

<File>c:\documents and settings\propriétaire\bureau\ey-lord\ey-lord.cpp</File>

But this, is ok [short path in release mode ]

<File>.\ey-lord.cpp</File>

the error message [ translate from french by me ... ]

An incorrect text caracter has been found in a text container. Error when trying to work on the ressource
file:///C:/Documents and...

<File>c:\documents and settings\propri



Maybe the tag name File is not allowed in html/xml ... i'll check on that .

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!