Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Using #line directive

Thread Tools

Re: Using #line directive

Alf P. Steinbach
Posts: n/a
* 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.
> #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?
Reply With Quote
Richard Heathfield
Posts: n/a
Alf P. Steinbach said:


> 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
email: rjh at the above domain, - www.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using-declaration or using-directive inside unnamed-namespace? Niels Dekker - no reply address C++ 1 04-27-2010 04:16 PM
Examine items in the ASP.NET cache added using the OutputCache directive Edward Wilde ASP .Net 1 12-10-2004 01:44 AM
using-declaration vs. using-directive Insert Pseudonym Here C++ 1 05-03-2004 09:36 AM
The 'Location' attribute is not supported by the 'OutPutCache' directive????when i set in the directive .NET Follower ASP .Net 1 02-13-2004 10:32 AM
using Include directive in ASP .NET Farooq Khan ASP .Net 1 10-28-2003 02:10 PM