RE: [Dev-C++] #DEFINE versus cont variables in array inicializations
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@em...> - 2003-05-29 20:15:48
|
> -----Original Message----- > From: Per Westermark [mailto:pw...@ia...] > Sent: Friday, May 30, 2003 2:00 AM > To: Ioannis Vranos > Cc: Dev-C++ Mailing List > Subject: RE: [Dev-C++] #DEFINE versus cont variables in array > inicializations > > > I guess you don't think of gcc as a decent compiler then. > > try gcc -O3 -S on the code below and look at the output. > 4 byte for the value 7 > 4 byte for the SIZE reference. > access loads SIZE and pushes [SIZE] (4 byte addr info + extra instr) > > with const int SIZE = 7 > zero byte for value > every access pushes 7 directly. (4 byte value) > > Most compilers treat 'const int v = <value>' identical to #define XX > <value>, i.e. optimal code is generated. ... and we are talking about C++ here, so g++ is the compiler and not gcc. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |