Standard library macros

K

Keith Thompson

Nobody said:
No it can't. You're not talking about "functions", but "special forms".
Just because something uses the syntax "name(argument list)", that doesn't
make it a function.

There isn't a single *function* in the standard which requires special
treatment from the compiler. Anything which looks like a function either
can be implemented in a library on any sane platform or is a macro.


If you want C++, you know where to find it.

I don't think C++ functions or templates can implement offsetof()
(which takes a member name as an argument) or assert() (which
requires source level information from the point of invocation)
any better than C can.
 
M

Malcolm McLean

There are a couple of cases, such as getc() and putc(), where a
macro implementation was allowed to evaluate its argument more than
once.  These were allowed for efficiency issues.  Where it actually
makes a difference, I'm not so sure the efficiency issue has actually
gone away.
I never use getc(), and the efficiency difference with fgetc() has
never been a problem.
 
J

jacob navia

Le 13/11/10 03:13, Eric Sosman a écrit :
Show us your implementations of offsetof(), setjmp(), and
assert() as functions, and *then* we'll talk.

For an implementation of setjmp as a function see lcc-win.
 
P

Peter Nilsson

Eric Sosman said:
...
     Show us your implementations of offsetof(), setjmp(), and
assert() as functions, and *then* we'll talk.

There are quite a few implementations of setjmp() as a function.
What surprises me is that longjmp() is required to exist as a
function.
 
P

Peter Nilsson

<snip more beer milkshakes>

sandeep said:
Sometimes I imagine that you and Mr Sosmanji just look for
reasons to oppose my suggestions...

Well someone has to, because you clearly don't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,083
Messages
2,570,590
Members
47,211
Latest member
JaydenBail

Latest Threads

Top