RE: [Dev-C++] #DEFINE versus cont variables in array inicializations
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-05-29 19:01:38
|
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. /Per W On Thu, 29 May 2003, Ioannis Vranos wrote: > A third way that guarantees no space occupation by a decent compiler is: > > > const int &SIZE = 7; > > > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: eBay > Get office equipment for less on eBay! > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |