help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GURU NEEDED : macro SQUARE(x) for any type x


From: bolega
Subject: GURU NEEDED : macro SQUARE(x) for any type x
Date: Thu, 13 Jan 2011 22:46:24 -0800 (PST)
User-agent: G2/1.0

Basically, I have spent a few hours experimenting and searching on the
comp.lang.c/c++

Let me use SQR for brevity and saving line

Here are progressively refined macros :

#define SQR(x) ((x)*(x))

#define SQR(x) ({typedef xtype=x; xtype xval=x; xval*xval})  // NOTE,
closure or {} inside () is a valid idea in C, and thus no return is
needed.

this macro is given in several posts like

http://groups.google.com/group/comp.lang.lisp/browse_frm/thread/38ef2b108e325da6/e5fe657622e5595b?q=%22typedef+xtype%22&pli=1

there is a problem with typedef

Bolega


reply via email to

[Prev in Thread] Current Thread [Next in Thread]