Re: Performance, for(int i...) vs for(i...)

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

 



On 26/08/12 20:41, Tim Prince wrote:
On 8/26/2012 1:56 PM, Georg-Johann Lay wrote:
Tim Prince schrieb:
On 08/26/2012 11:30 AM, lab@xxxxxxxxxxxxx wrote:
Hello, I like performance, and until last month i follow what I see
on the web to do better coding for performance, like:

- Avoid i++, use ++i and so on.

But now i'm using the assembly (-S) code generated to see if
somethings is correct, and today i'm investigating this:

int i;
for(i = 0;....);

vs

for(int i = 0;...);

[...] It's probably important to continue to handle the declaration
outside the scope well, as that version is required for C source code
by Microsoft compilers, even VS2012.
I have had occasion to wish that people didn't rely on non-standard
maybe Microsoft is right in forbidding both incorrect and correct C++
usage in C code.

It's all vanilla C99, no C++ is needed for that.

Just activate that language standard in your C compiler ;-)

Johann


Nothing wrong with maintaining compatibility with a widely marketed
compiler, even if gcc does the job better.


Are you suggesting that people who use gcc should limit themselves and the quality of the code they write because some other manufacturer makes a half-hearted C compiler that they hope no one will ever use? MS supports C++ (with their own additions), C# and VB (their own proprietary languages) - they haven't supported C properly for something like a decade.

If you want to use MS tools, that's fine - but use the tools they actually recommend you use. And if you want to write C, use a real C compiler.

There are many features of C99 that are good additions to making C a better language, and you should use them when writing C code.


[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