macros question

  • Follow


so, we have built-in __FILE__ and __LINE__

how could we define 
__FILELINE__ macros so it would be smth like, for example, "file.c:11"

i've tried
#define __FILELINE__ __FILE__ ## ":" ## __LINE__
and 
#define __FILELINE__ __FILE__ ## ":" ## #__LINE__

and a bunch of different combinations but none work for me :(
0
Reply arro (16) 4/4/2004 8:26:40 PM

begin  followup to Andrew Arro:
> how could we define 
> __FILELINE__ macros so it would be smth like, for example, "file.c:11"

$ nl -ba f.c 
     1  #include <stdio.h>
     2
     3  #define QUOTE_STR(s)    #s
     4  #define QUOTE_NUM(n)    QUOTE_STR(n)
     5  #define __FILELINE__    __FILE__ ":" QUOTE_NUM(__LINE__)
     6
     7  int main()
     8  {
     9    puts(__FILELINE__);
    10    return 0;
    11  }
$> gcc -Wall f.c && ./a.out 
f.c:9

> i've tried
> #define __FILELINE__ __FILE__ ## ":" ## __LINE__
> and 
> #define __FILELINE__ __FILE__ ## ":" ## #__LINE__

Nonsense.

-- 
F�r Google, Tux und GPL!
0
Reply alexander.bartolich (131) 4/4/2004 8:36:32 PM


"Andrew Arro" <arro@arro.ru> a �crit dans le message de
news:17118df1.0404041226.6ba26237@posting.google.com...
> so, we have built-in __FILE__ and __LINE__
>
> how could we define
> __FILELINE__ macros so it would be smth like, for example, "file.c:11"
>
> i've tried
> #define __FILELINE__ __FILE__ ## ":" ## __LINE__
> and
> #define __FILELINE__ __FILE__ ## ":" ## #__LINE__
>
> and a bunch of different combinations but none work for me :(

Hi,

You can take a look at the 11.7 FAQ to stringize macros.

I suggest you this example :

/********/
/* exple.c */
/********/
#include <stdio.h>

/* stringizing stuff */
#define GEN_STRING(x) #x
#define STRINGIZE(x) GEN_STRING(x)

/* stringize expanded built-in macros __FILE__ and __LINE __*/
#define FILELINE STRINGIZE(__FILE__ : __LINE__)

int main(void)
{
  printf(FILELINE "\n");
  return 0;
}

/* That's all folks */

Notes :
1) I would avoid beginning my identifiers with __, since many predefined
macros and others use it.
2) assert() already displays informations using __FILE__ and __LINE__

HTH
Regis



0
Reply regt (82) 4/4/2004 10:04:41 PM

"Alexander Bartolich" <alexander.bartolich@gmx.at> wrote in message
news:c4prkg$2l2jeb$1@ID-193444.news.uni-berlin.de...

Please STOP posting attachments to this newsgroup.
If you have code to share, paste it into the
body of your message (text only).

-Mike



0
Reply mkwahler (3821) 4/5/2004 1:20:20 AM

"Mike Wahler" <mkwahler@mkwahler.net> writes:

> "Alexander Bartolich" <alexander.bartolich@gmx.at> wrote in message
> news:c4prkg$2l2jeb$1@ID-193444.news.uni-berlin.de...
>
> Please STOP posting attachments to this newsgroup.

He didn't post any attachments.  His article was plain text only.
However, I see that you're posting using a broken newsreader.
Fix that and you'll have no problems.
-- 
"Debugging is twice as hard as writing the code in the first place.
 Therefore, if you write the code as cleverly as possible, you are,
 by definition, not smart enough to debug it."
--Brian Kernighan
0
Reply blp (3953) 4/5/2004 1:53:26 AM

On Mon, 05 Apr 2004 01:20:20 GMT, "Mike Wahler"
<mkwahler@mkwahler.net> wrote in comp.lang.c:

> 
> "Alexander Bartolich" <alexander.bartolich@gmx.at> wrote in message
> news:c4prkg$2l2jeb$1@ID-193444.news.uni-berlin.de...
> 
> Please STOP posting attachments to this newsgroup.
> If you have code to share, paste it into the
> body of your message (text only).
> 
> -Mike

What attachment?  The post you are complaining about was plain text.

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
0
Reply jackklein (3932) 4/5/2004 3:26:09 AM

Mike Wahler wrote:

> "Alexander Bartolich" <alexander.bartolich@gmx.at> wrote in message
> news:c4prkg$2l2jeb$1@ID-193444.news.uni-berlin.de...
> 
> Please STOP posting attachments to this newsgroup.
> If you have code to share, paste it into the
> body of your message (text only).

Actually, he did not post an attachment.  What he *did* do was to begin 
his post with
 >>  begin  followup to Andrew Arro:
which your Microsoft Outlook Express 6.00.2800.1106 decided to treat as 
signalling an attachment.

Alexander, if you want your messages to be read, do not start them with 
the word "begin."


0
Reply mambuhl (2201) 4/5/2004 3:59:54 AM

Mike Wahler wrote:

> 
> "Alexander Bartolich" <alexander.bartolich@gmx.at> wrote in message
> news:c4prkg$2l2jeb$1@ID-193444.news.uni-berlin.de...
> 
> Please STOP posting attachments to this newsgroup.

Mike, there are lots of newsreaders out there that work just fine. So why 
are you using a broken one? :-)

-- 
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
0
Reply dontmail (1884) 4/5/2004 6:48:22 AM

Martin Ambuhl <mambuhl@earthlink.net> spoke thus:

> Alexander, if you want your messages to be read, do not start them with 
> the word "begin."

ITYM "if you want your messages to be read by Mike", as most of us had
no difficulty :)

-- 
Christopher Benson-Manica  | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org    | don't, I need to know.  Flames welcome.
0
Reply ataru (1609) 4/5/2004 5:11:59 PM

Christopher Benson-Manica <ataru@nospam.cyberspace.org> writes:
> Martin Ambuhl <mambuhl@earthlink.net> spoke thus:
> 
> > Alexander, if you want your messages to be read, do not start them with 
> > the word "begin."
> 
> ITYM "if you want your messages to be read by Mike", as most of us had
> no difficulty :)

There are two problems here.

1. Some newsreader(s) incorrectly interpret a line in the body of a
message starting with "begin  " as the beginning of an attachment.
(If there's a way to disable this misfeature, someone could save us
all a lot of trouble by letting us know how to do it.)  I'm guessing
that a bug report has already been submitted; it would probably be a
good idea for anyone who uses the newsreader(s) in question to
encourage the vendor to fix it.

2. Alexander deliberately antagonizes users of the broken
newsreader(s) in question by posting articles containing lines
starting with "begin  ".  (I don't believe it's accidental; the double
space after the "begin" is too specific.)  I humbly submit that
Alexander has made his point, and that it's time for him to knock it
off.  Antagonizing the authors of broken newsreaders is just fine.
Antagonizing the users of broken newsreaders, who may or may not have
a real choice in the matter and who may or may not have any influence
over the vendor, is questionable, but I won't argue that he shouldn't
do it.  Indirectly antagonizing the entire readership of comp.lang.c
(because Alexander should know by now what the response is going to
be) may have seemed like a good idea at the time, but it's no longer
serving any useful purpose.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
0
Reply kst-u (21545) 4/5/2004 8:19:26 PM

Keith Thompson wrote:

> Indirectly antagonizing the entire readership of comp.lang.c
> (because Alexander should know by now what the response is going to
> be) may have seemed like a good idea at the time, but it's no longer
> serving any useful purpose.

Not quite the /entire/ readership. :-)

-- 
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
0
Reply dontmail (1884) 4/5/2004 8:45:21 PM

Richard Heathfield <dontmail@address.co.uk.invalid> wrote:

> Keith Thompson wrote:
> 
> > Indirectly antagonizing the entire readership of comp.lang.c
> > (because Alexander should know by now what the response is going to
> > be) may have seemed like a good idea at the time, but it's no longer
> > serving any useful purpose.
> 
> Not quite the /entire/ readership. :-)

Ditto. OutLook is OutDated, and should be OutStamped.

Richard
0
Reply rlb (4118) 4/6/2004 7:30:43 AM

Richard Bos <rlb@hoekstra-uitgeverij.nl> scribbled the following:
> Richard Heathfield <dontmail@address.co.uk.invalid> wrote:
>> Keith Thompson wrote:
>> > Indirectly antagonizing the entire readership of comp.lang.c
>> > (because Alexander should know by now what the response is going to
>> > be) may have seemed like a good idea at the time, but it's no longer
>> > serving any useful purpose.
>> 
>> Not quite the /entire/ readership. :-)

> Ditto. OutLook is OutDated, and should be OutStamped.

I agree with the Richards.

-- 
/-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A bee could, in effect, gather its junk. Llamas (no poor quadripeds) tune
and vow excitedly zooming."
   - JIPsoft
0
Reply palaste (2323) 4/6/2004 8:46:14 AM

Richard Bos wrote:
> Richard Heathfield <dontmail@address.co.uk.invalid> wrote:
>> Keith Thompson wrote:
>>
>>> Indirectly antagonizing the entire readership of comp.lang.c
>>> (because Alexander should know by now what the response is
>>> going to be) may have seemed like a good idea at the time,
>>> but it's no longer serving any useful purpose.
>>
>> Not quite the /entire/ readership. :-)
> 
> Ditto. OutLook is OutDated, and should be OutStamped.

The problem with the "solution" is that lusers of the inferior
buggy software will never realize what is going on.  Now if that
initial "begin  " could be replaced by something that would flash
"Your @#$% reader is bug-infested" in large letters at about 2
flashes per second on ONLY the aforesaid bug-infested software, we
would have something worth while.

-- 
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


0
Reply cbfalconer (19183) 4/6/2004 11:43:08 AM

CBFalconer <cbfalconer@yahoo.com> writes:

> The problem with the "solution" is that lusers of the inferior
> buggy software will never realize what is going on.  Now if that
> initial "begin  " could be replaced by something that would flash
> "Your @#$% reader is bug-infested" in large letters at about 2
> flashes per second on ONLY the aforesaid bug-infested software, we
> would have something worth while.

Here's an approximation:

begin 644 foo
A66]U<B!`(R0E(')E861E<B!I<R!B=6<M:6YF97-T960*
`
end
-- 
"The lusers I know are so clueless, that if they were dipped in clue
 musk and dropped in the middle of pack of horny clues, on clue prom
 night during clue happy hour, they still couldn't get a clue."
--Michael Girdwood, in the monastery
0
Reply blp (3953) 4/6/2004 5:05:11 PM

Ben Pfaff <blp@cs.stanford.edu> scribbled the following:
> CBFalconer <cbfalconer@yahoo.com> writes:
>> The problem with the "solution" is that lusers of the inferior
>> buggy software will never realize what is going on.  Now if that
>> initial "begin  " could be replaced by something that would flash
>> "Your @#$% reader is bug-infested" in large letters at about 2
>> flashes per second on ONLY the aforesaid bug-infested software, we
>> would have something worth while.

> Here's an approximation:

> begin 644 foo
> A66]U<B!`(R0E(')E861E<B!I<R!B=6<M:6YF97-T960*
> `
> end

For us who use non-broken newsreaders (such as tin), and don't want to
go through the hassle of Base64-converting it by hand, what does it do?

-- 
/-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You will be given the plague."
   - Montgomery Burns
0
Reply palaste (2323) 4/6/2004 5:21:13 PM

Joona I Palaste <palaste@cc.helsinki.fi> writes:

> Ben Pfaff <blp@cs.stanford.edu> scribbled the following:
>> CBFalconer <cbfalconer@yahoo.com> writes:
>>> The problem with the "solution" is that lusers of the inferior
>>> buggy software will never realize what is going on.  Now if that
>>> initial "begin  " could be replaced by something that would flash
>>> "Your @#$% reader is bug-infested" in large letters at about 2
>>> flashes per second on ONLY the aforesaid bug-infested software, we
>>> would have something worth while.
>
>> Here's an approximation:
>
>> begin 644 foo
>> A66]U<B!`(R0E(')E861E<B!I<R!B=6<M:6YF97-T960*
>> `
>> end
>
> For us who use non-broken newsreaders (such as tin), and don't want to
> go through the hassle of Base64-converting it by hand, what does it do?

It decodes to "Your @#$% reader is bug-infested".
-- 
"I hope, some day, to learn to read.
 It seems to be even harder than writing."
--Richard Heathfield
0
Reply blp (3953) 4/6/2004 6:19:16 PM

Ben Pfaff <blp@cs.stanford.edu> scribbled the following:
> Joona I Palaste <palaste@cc.helsinki.fi> writes:
>> Ben Pfaff <blp@cs.stanford.edu> scribbled the following:
>>> CBFalconer <cbfalconer@yahoo.com> writes:
>>>> The problem with the "solution" is that lusers of the inferior
>>>> buggy software will never realize what is going on.  Now if that
>>>> initial "begin  " could be replaced by something that would flash
>>>> "Your @#$% reader is bug-infested" in large letters at about 2
>>>> flashes per second on ONLY the aforesaid bug-infested software, we
>>>> would have something worth while.
>>
>>> Here's an approximation:
>>
>>> begin 644 foo
>>> A66]U<B!`(R0E(')E861E<B!I<R!B=6<M:6YF97-T960*
>>> `
>>> end
>>
>> For us who use non-broken newsreaders (such as tin), and don't want to
>> go through the hassle of Base64-converting it by hand, what does it do?

> It decodes to "Your @#$% reader is bug-infested".

With or without the large letters at about 2 flashes per second? =)

-- 
/-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Stronger, no. More seductive, cunning, crunchier the Dark Side is."
   - Mika P. Nieminen
0
Reply palaste (2323) 4/6/2004 7:52:12 PM

Joona I Palaste wrote:
> Ben Pfaff <blp@cs.stanford.edu> scribbled the following:
> 
>>CBFalconer <cbfalconer@yahoo.com> writes:
>>
>>>The problem with the "solution" is that lusers of the inferior
>>>buggy software will never realize what is going on.  Now if that
>>>initial "begin  " could be replaced by something that would flash
>>>"Your @#$% reader is bug-infested" in large letters at about 2
>>>flashes per second on ONLY the aforesaid bug-infested software, we
>>>would have something worth while.
> 
> 
>>Here's an approximation:
> 
> 
>>begin 644 foo
>>A66]U<B!`(R0E(')E861E<B!I<R!B=6<M:6YF97-T960*
>>`
>>end
> 
> 
> For us who use non-broken newsreaders (such as tin), and don't want to
> go through the hassle of Base64-converting it by hand, what does it do?
> 
It is uuencoded and represents ascii..

Your @#$% reader is bug-infested

-- 
Joe Wright                            mailto:joewwright@comcast.net
"Everything should be made as simple as possible, but not simpler."
                     --- Albert Einstein ---
0
Reply joewwright (1737) 4/6/2004 10:16:20 PM

In <c4uou9$7db$1@oravannahka.helsinki.fi> Joona I Palaste <palaste@cc.helsinki.fi> writes:

>Ben Pfaff <blp@cs.stanford.edu> scribbled the following:
>> CBFalconer <cbfalconer@yahoo.com> writes:
>>> The problem with the "solution" is that lusers of the inferior
>>> buggy software will never realize what is going on.  Now if that
>>> initial "begin  " could be replaced by something that would flash
>>> "Your @#$% reader is bug-infested" in large letters at about 2
>>> flashes per second on ONLY the aforesaid bug-infested software, we
>>> would have something worth while.
>
>> Here's an approximation:
>
>> begin 644 foo
>> A66]U<B!`(R0E(')E861E<B!I<R!B=6<M:6YF97-T960*
>> `
>> end
>
>For us who use non-broken newsreaders (such as tin), and don't want to
>go through the hassle of Base64-converting it by hand, what does it do?

Non-broken newsreaders should be able to handle uuencoded content just
fine, since this is the de facto standard binary encoding method of the 
Usenet.  Consider your newsreader broken if it cannot, at least, create
a file named foo and containing the decoded data, upon your explicit 
request.

Dan
-- 
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de
0
Reply Dan.Pop (3615) 4/7/2004 2:22:32 PM

19 Replies
47 Views

(page loaded in 0.233 seconds)


Reply: