Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: Using #line directive (http://www.velocityreviews.com/forums/t458840-re-using-line-directive.html)

Alf P. Steinbach 11-30-2006 05:13 AM

Re: Using #line directive
 
* AA:
> Hi,
> I have a C++ project in DOT NET. I am using the __FILE__ and __LINE__
> to print the current file and line number. I do not want the file anem
> with the full path to be printed. So I used the #line directive.
>
>
Code:

>
> #line 3 "11.cpp"
>
>

>
> Still the full file name along with the name (11.c) gets printed. If I
> change 11.c above and type something else, say trial.cpp, the full file
> path along with trial.cpp gets printed. How can I just get the file
> name printed using __FILE__?
>
> Regards,
> AA
>


You have multi-posted to comp.lang.c++ and alt.comp.lang.learn.c-c++ and
for all I know to more groups.

Please don't.

Re your question you can parse the filename in the code it's passed to,
that means, scanning from the right to find the rightmost delimiter such
as / or \. Standard C++ does not provide any means to get the "bare"
file name directly. And DOT NOT is OFF TOPIC in comp.lang.c++, which
deals only with the C++ language (and some general, portable libraries).

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Richard Heathfield 11-30-2006 06:27 AM

Re: Using #line directive
 
Alf P. Steinbach said:

<snip>

> And DOT NOT is OFF TOPIC in comp.lang.c++, which
> deals only with the C++ language (and some general, portable libraries).


The .NET environment is also off-topic in alt.comp.lang.learn.c-c++ - but
(as you are undoubtedly aware) the question was a reasonable one, for which
portable solutions, such as the one you gave, exist.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.


All times are GMT. The time now is 10:38 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.