unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* GURU NEEDED : macro SQUARE(x) for any type x
@ 2011-01-14  6:46 bolega
  2011-01-14  7:09 ` luser- -droog
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: bolega @ 2011-01-14  6:46 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: bolega

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-01-15 19:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-14  6:46 GURU NEEDED : macro SQUARE(x) for any type x bolega
2011-01-14  7:09 ` luser- -droog
2011-01-14  7:10 ` Rivka Miller
2011-01-14  7:15 ` luser- -droog
2011-01-14  8:14   ` Hans Vlems
2011-01-14  9:04     ` luser- -droog
2011-01-14  8:51 ` Gert-Jan de Vos
2011-01-14 11:13   ` James Kuyper
2011-01-14 20:01     ` Stefan Monnier
2011-01-14 21:57       ` James Kuyper
2011-01-14  9:57 ` Bart van Ingen Schenau
2011-01-15  2:24 ` PKM
2011-01-15 19:55   ` Keith Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).