Re: Let gcc generate a warning or an error?

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

 



Georg-Johann Lay <avr@xxxxxxxx> writes:


If you want to ask a new question, please send a new message to the
mailing list, do not reply to an existing message.  When you reply to
an existing message, your message will get threaded incorrectly by
most mail reading programs.  Thanks.


> Hi, I would like to do something like
>
> static inline void foo (unsigned long x)
> {
>     if (__builtin_constant_p (x))
>     {
>         asm volatile ("... %0" :: "n" (x));
>     }
>     else
>     {
>         __builtin_error ("foo must be used with a compile time constant");
>     }
> }
>
> Is there a way to generate an error/warning/info by making gcc
> call error/warning/info?
>
> So that in the above case an understandable error message is printed.

Not really, no.  It would be a useful feature.  In C++ you can use
template tricks to implement this.


> Is there an anologon to __builtin_constant_p that is true for compile
> time constants only (constraint "n" in the abobe case, but not all
> of "i")?

No.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux