Browsing all articles tagged with encapsulation with macro - Share Programming Tips
What’s the need of using encapsulation { do..while(0) block } in define a macro in C programming?
While reading many codes in c programming based open source project i came to know one interesting things. Let me explain you by some sample code.
#define Assert(v) if(!(v)) printf("Error occurred at: %s, in %s at %i", #v, __FILE__, __LINE__); |
At most of the experienced people used to write such macro in following style
#define Assert(v) do { if(!(v)) printf("Error occurred at: %s, in %s at %i", #v, __FILE__, __LINE__); } while(0) |
This method is called as making encapsulating our macro.
Now let me explain you whats the need of this….
Search in this website
our sponsors
latest comments
- shinto peter on How to configure mail from localhost ( wamp ) using PHP?
- tammylleanne on Implementation limitation of c programming language
- Deepak on How to access/unblock songs.pk in india?
- Deepak on How to access/unblock songs.pk in india?
- prk on How to access/unblock songs.pk in india?
Find us on Facebook
Top Authors
Find us on stackoverflow
Polls
Loading ...
My Bookmarks
- Audio/video Recorder & player application based on MATLAB
- check dependency of your binary
- defination of all standard c programming language function
- Great Question-Answer on c programming
- know what your c code means
- Limition of c programming language
- List of all version of c programming language
- Online c compiler
- php freelancing work
- some more stuff on C programming language
- Volatile Keyword in Embedded System
- Write Android application in c language