Tutorials
Resources
Forum
Communities
Interview
Jobs
Projects
Offshore Development
Silverlight Tutorials
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Revenue Sharing
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Abhi
(63)
Appukuttan
(40)
divya
(36)
Last 7 Days
Appukuttan
(660)
Babu Akkandi
(465)
Tejinder Singh ...
(273)
more...
New Feature:
Community Sites
:
Create your own .NET community website and start earning from Google AdSense !
It's Free !
Prefer const and inline to #define macros in C/C++
Posted Date: 19 Jun 2008
Resource Type:
Errors and Solutions
Category:
General
Author:
Lekshmi m nair
Member Level:
Silver
Rating:
Points
: 3
When you do something like this,
#define ASPECT_RATIO 1.653
the symbolic name ASPECT_RATIO may never be seen by compilers; it may be removed by the preprocessor before the source code ever gets to a compiler. So if you get an error during compilation involving the use of this constant, the error decription may not contain the symbolic name ASPECT_RATIO.
Instead of using a preprocessor macro, define a constant like
const double ASPECT_RATIO = 1.653;
to solve the issue. Instead of using #define directive to implement macros that look like functions, use inline functions.You can get all the efficiency of a macro plus all the predictable behavior and type-safety of a regular function.
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
Prefer inline to macros
.
Prefer constants to macros
.
Prefer constants and inline functions to macros
.
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
100 % CPU utilization shown when DoEvents is used
Previous Resource:
'Problem in Connecting Database
Return to Discussion Resource Index
Post New Resource
Category:
General
Post resources and
earn money
!
Related Resources
error CS5001
Breakpoints not working in Visual Web Developer 2005 express edition
Packages
How to avoid prompt while Closing IE Window
How to avoid Multiple selection not allowed in DropDownList problem
dotNet Slackers
BizTalk Adaptors
Web Design
Contact Us
Privacy Policy
Terms Of Use