| Deutsch English Français Italiano |
|
<vuah44$2usfh$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Muttley@DastardlyHQ.org
Newsgroups: comp.lang.c
Subject: Re: Loops (was Re: do { quit; } else { })
Date: Wed, 23 Apr 2025 10:58:12 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <vuah44$2usfh$1@dont-email.me>
References: <vspbjh$8dvd$1@dont-email.me> <vu01k7$1bfv2$1@dont-email.me>
<vu0720$1dva7$1@dont-email.me> <vu2hmg$3jn88$1@dont-email.me>
<vu2mkc$3noft$1@dont-email.me> <vu38da$735n$1@dont-email.me>
<vu3j7s$g755$1@dont-email.me> <87ecxmv4t4.fsf@nosuchdomain.example.com>
<vu401g$reom$1@dont-email.me> <20250420200823.908@kylheku.com>
<vu5bqp$230jl$2@dont-email.me> <20250421113640.839@kylheku.com>
<vu67up$2ubvr$1@dont-email.me> <20250421125957.29@kylheku.com>
<vu6kkt$392e6$1@dont-email.me> <vu6q3b$3jhq1$1@paganini.bofh.team>
<vu7r19$da0o$1@dont-email.me> <20250422103555.547@kylheku.com>
<vu8sm8$18fhc$2@dont-email.me> <20250422142113.403@kylheku.com>
<vu99ir$1j6ll$2@dont-email.me> <20250422164415.883@kylheku.com>
<vuaej6$2q2co$1@dont-email.me>
Injection-Date: Wed, 23 Apr 2025 12:58:12 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7ca9f6b3c496151fa10fed8be15037ad";
logging-data="3109361"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jnqw8Z/0+lElppeDqn3Va"
Cancel-Lock: sha1:sqXcaSYxIIT2TFD3BeuDZJgARyg=
Bytes: 2798
On Wed, 23 Apr 2025 11:15:01 +0100
bart <bc@freeuk.com> wibbled:
>IMV, macros generally are a bad idea. They are especially bad with how
>they are implemented in C:
C macros do essentially 4 different things:
1) Provide a way to pass compilation data directly into the code via compiler
switches and #ifdef
2) Allow conditional compilation for different OS's
3) Allow repeating blocks of code to be compacted into a single macro when
having a function instead would be more complicated and/or inefficient.
4) An alternative to inline functions. Probably the least useful.
>* Their implementation is complex and poorly defined.
Maybe to you.
>* Compiler error messages can get weird and confusing
If you think C errors are confusing try C++ with template errors.
>* They cause problems for tools such as smart editors
Any "smart" editor that can't cope with macros isn't smart.
>* Macros don't obey normal scope rules.
They're not supposed to.
>* Macro solutions tend to be ugly and tacky (see X-macros)
So can any code.
>* Macro expansion can do too much:
>
> #define length 200
> #define width 100
>
> struct {char* str; int length;} s;
> s.length = 0; // oops!
So what? You'd get a compilation error.