Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.c > #392876
| From | Ben Bacarisse <ben@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: enums and switch vs function calls |
| Date | 2025-04-25 01:12 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <875xithzes.fsf@bsb.me.uk> (permalink) |
| References | <vsr0ml$1to9m$1@dont-email.me> <enum-20250405122329@ram.dialup.fu-berlin.de> <1ybIP.1259194$2zn8.458292@fx15.iad> <86y0wdfvc0.fsf@linuxsc.com> <FtwIP.1525960$eNx6.1342019@fx14.iad> |
scott@slp53.sl.home (Scott Lurndal) writes: > Tim Rentsch <tr.17687@z991.linuxsc.com> writes: >>scott@slp53.sl.home (Scott Lurndal) writes: >> >>> ram@zedat.fu-berlin.de (Stefan Ram) writes: >>> >>>> Richard Harnden <richard.nospam@gmail.invalid> wrote or quoted: >>>> >>>>> int hex = colour_to_hex(10); >>>>> ... then the compiler doesn't complain that 10 is not in the enum. >>>>> Why? Surely the compiler can tell. >>>> >>>> I get >>>> >>>> | >>>> |error: enum conversion when passing argument 1 of 'colour_to_hex' is >>>> invalid in C++ [-Wc++-compat] >>>> | |int hex = colour_to_hex(10); >>>> | | ^~ >>>> |note: expected 'enum colour' but argument is of type 'int' >>>> | | int colour_to_hex(enum colour colour) >>>> | | ^~~~~~~~~~~~~ >>>> | >>>> >>>> with >>>> >>>> gcc -Wc++-compat >>> >>> That example exemplifies the seriously screwed up error reporting in the >>> gnu compiler collection. >>> >>> One line of informative error message followed by 5 lines of useless >>> cruft to wade through. And no way to turn it off completely. >> >>That's true, but it can be reduced to only two lines total (so only one >>line more than needed), by using -fno-diagnostics-show-caret. > > Yes, I use that. I still find that the "note:" lines clutter the > output and provide zero benefit. Does gcc -fcompare-debug-second -fno-diagnostics-show-caret do what you want? The behaviour seems to be a side effect of some internal debug options so it probably can't be relied upon long-term. -- Ben.
Back to comp.lang.c | Previous | Next | Find similar
Re: enums and switch vs function calls Ben Bacarisse <ben@bsb.me.uk> - 2025-04-25 01:12 +0100
csiph-web