Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: How to compile several C files Date: Wed, 08 Feb 2017 09:27:46 -0800 Organization: None to speak of Lines: 25 Message-ID: References: <137458b9-1471-27ef-8c1e-8d9e781f315f@verizon.net> <5b6f9245-8bdf-4365-8a73-201c192f6980@googlegroups.com> <8760klby18.fsf@bsb.me.uk> <87d1esafr0.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="4a721828f74a91b51542c19008c4da11"; logging-data="13437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6Vv2W89x8oEXKTrhHu1Ut" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:DB6NhMjwhsLCOQZKbYSyUdI1FQ4= sha1:Y7otgRQ0q8SQRMwadTrtZDPVL4A= Xref: csiph.com comp.lang.c:103480 David Brown writes: [...] > What you can do, and I have done, is something like: > > // In one C file > int counter_private; > > // In header file > extern int counter_private; // Do not use! > #define counter ((const int) counter_private) Note that the const in the cast is probably useful as documentation, but it's not really necessary, since a cast expression is not an lvalue. You could also have: #define counter (+counter_private) [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"