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: Preprocessor Overheads Date: Thu, 02 Feb 2017 13:06:03 -0800 Organization: None to speak of Lines: 47 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="523b5027be519a02b651eac1ee0346e8"; logging-data="7421"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qvGxpjnRn8rerKAP09NZ5" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Y27BGUFPordRzc2kj7gf0iPf97o= sha1:lGrOVNykLyHmNY/iq78yqULt8s4= Xref: csiph.com comp.lang.c:102981 BartC writes: [...] > I can already write in original source: > > int64 a > print a > > which I can translate, when I need portable output, to: > > int64_t a; > printf("%lld", a)' That's not portable output. > Except that that "ll" causes problems on gcc on Windows, with the > warning level high enough, and on the Linux, because there are too many > l's. (The code however will still run. The capabilities of a printf > function ought to be outside the remit of a compiler.) I'm surprised that you're getting the particular warnings you report from gcc, but the fact that you're getting *some* warnings shouldn't be a problem, since the code is non-portable. (BTW, what compiler options are you using?) "%lld" is for type long long int. int64_t may or may not be the same type. Either convert to long long int and use "%lld" (and figure out how to get your gcc to suppress its incorrect warning), or use the PRId64 macro. Those are your options if you want to write or generate correct and portable C. You have other options if you don't. If you have other questions that haven't already been asked and answered, feel free to ask. > Are you suggesting that I should instead generate C++ and use 'cout'? My > experience is that even if that solves one problem, it introduces dozens > more. I also have far less choice of compilers, and code will take > longer to compile. Using `std::cout << a` would certainly solve the problem of picking the right format string (which isn't really much of a problem). No doubt it would introduce other problems. -- 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"