public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Christian Häggström" <97nv46@skola.kiruna.se>
To: <J.A.K.Mouw@its.tudelft.nl>
Cc: <gcc@gcc.gnu.org>
Subject: Re: Volatile constants?
Date: Wed, 29 Mar 2000 23:31:00 -0000	[thread overview]
Message-ID: <s8e31eb4.024@ymer> (raw)

/* Okay I forgot the parenthesis, but that was not my point */

The GCC manual says "An Inline Function is As Fast As a Macro",
but when I compile this (as C code), I got error "initializer element is not constant" on
's' initialization.

inline int abs1(int x) {
    return x<0 ? -x : x;
}
#define abs2(x) ((x)<0 ? -(x) : (x))

int r = abs1(-7);
int s = abs2(-7);

Is there any option I have to pass?

>I don't get that error message. Here is what my compiler says: ...

Okay you use g++. I use the c compiler.
g++ don t generate an error (not even a warning) for this,
but makes an constructor function, 'static_initialization_and_destruction'-something
That is not what I want and it is NOT as fast as a macro.

>I think you should upgrade to gcc-2.95.2.
I compiled with that version, yes

I ll be glad for any help

             reply	other threads:[~2000-03-29 23:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-29 23:31 Christian Häggström [this message]
2000-03-30  4:21 ` Richard Earnshaw
  -- strict thread matches above, loose matches on Subject: below --
2000-04-03  2:33 Christian Häggström
     [not found] <s8e49edd.056@ymer>
2000-03-31  3:17 ` Richard Earnshaw
2000-03-31  2:50 Christian Häggström
2000-03-29  4:57 Christian Häggström
2000-03-29  7:41 ` Erik Mouw
2000-03-29  9:53   ` Alasdair Baird
2000-03-29 10:05     ` Erik Mouw
2000-03-29  7:45 ` Kevin Handy
2000-03-29 12:18   ` Andi Kleen
2000-02-22  0:52 Christian Häggström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s8e31eb4.024@ymer \
    --to=97nv46@skola.kiruna.se \
    --cc=J.A.K.Mouw@its.tudelft.nl \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).