Explain Preprocessing

6 replies [Last post]
Isaac Yates
Isaac Yates's picture
Title: NooBot
Joined: 12/14/2013
Posts:
BotPoints: 19
User offline. Last seen 2 years 37 weeks ago.

Hi,

I am confused about a c programming concept. It has to do with the #ifndef and the #define. I understand that #ifndef DEFINITION checks to see if there are any previous #define DEFINITIONs called. My question is, why is this useful? An example I have run across was written by a retired team member:

#ifndef __OPENCODE_H__
#define __OPENCODE_H__

the header file then proceeds to include a number of headers that make up opencode, and then ends the file with a #endif. Here is the whole header file:

#ifndef __OPENCODE_H__
#define __OPENCODE_H__
#ifndef __arm__
#include "../config/cbcconfig.h"
#endif
#include "opencode/common/depthlib.h"
#include "opencode/cbc/drive/drivelib.h"
#include "opencode/cbc/light/lightstart.h"
#include "opencode/cbc/sensor/sensorlib.h"
#include "opencode/cbc/sensor/link_depth.h"
#include "opencode/cbc/servo/servolib.h"
#include "opencode/create/create_accel.h"
#include "opencode/create/create_config.h"
#include "opencode/create/create_drive.h"
#include "opencode/create/create_music.h"
#include "opencode/create/create_script.h"
#include "opencode/create/create_sensor.h"
#include "opencode/create/create_align.h"
#include "opencode/create/create_depth.h"
#endif

From what I can tell it has to do with something called preprocessing? Can someone explain to me importance (or unimportance) of defining __OPENCODE_H__ at all. I'd like to be able to intelligently write my own libs in the future (and teach others how to), and this seems important. Thanks.

“I have never let my schooling interfere with my education.” ~Mark Twain

Ponivnret
Title: NooBot
Joined: 07/29/2016
Posts:
BotPoints: 22
User offline. Last seen 1 year 19 weeks ago.

Thanks for making such a cool post which is really very well written.will be referring a lot of friends about this.Keep blogging.
get help with file explorer in windows 10

laurenjane
Title: NooBot
Joined: 08/29/2016
Posts:
BotPoints: 12
User offline. Last seen 1 year 11 weeks ago.

Well in my knowledge i think C is the easiest language if compared to Java,PHP etc.
Yes even better ans easier than HTML too.simple coding and features make it popular.
https://medium.com/@JauraJones/online-assignment-help-for-college-studen...

Rosealvin
Title: NooBot
Joined: 11/07/2016
Posts:
BotPoints: 4
User offline. Last seen 1 year 4 weeks ago.

I counsel you to pay money for from me bullion sophisticated by fire so that you might be wealthy, and pallid clothes to put on so that your disgraceful nudity may not be naked, and buy soothe to spread on your look at so that you may watch. Assignment Help – Assignment uk

daisyfaith
Title: NooBot
Joined: 03/22/2017
Posts:
BotPoints: 30
User offline. Last seen 13 weeks 2 hours ago.

I counsel you to pay money for from me bullion sophisticated by fire so that you might be wealthy, and pallid clothes to put on so that your disgraceful nudity may not be naked, and buy soothe to spread on your look at so that you may watch. buy thesis paper

annetrose
Title: NooBot
Joined: 07/06/2017
Posts:
BotPoints: 28
User offline. Last seen 7 weeks 1 day ago.

I think this is a relevant topic to get discussed and will be useful to students those who are studying programming. If you explain each program with a sample source code or its logic, then it will be more helpful to them to grasp the concept quickly.

hellenjos
Title: NooBot
Joined: 07/03/2017
Posts:
BotPoints: 90
User offline. Last seen 3 hours 10 min ago.

I am really fed up with this topic as I had tried many times to learn the concept but I didn’t understand a little bit of it. I have gone through this blog and found that the author share the idea in very simple way. Thanks for the great effort.JoyJolt highball glass