Go Down

Topic: BEGINNERS: #INCLUDE, #DEFINE, declarations, definitions and initialisation! (Read 936 times) previous topic - next topic

lastchancename

#INCLUDE, #DEFINE, declarations, definitions and initialisation in your code...

In addition to #INCLUDE, #DEFINE, #IF..., there are many other *preprocessor* directives.
https://en.m.wikipedia.org/wiki/C_preprocessor

All these keywords and methods determine very important parts of the way your program will compile and operate.
This brief introduction can't possibly be comprehensive... you need to explore and experiment to fully understand the intricacies of code development.

#INCLUDE
causes the contents of a second file to be inserted into the original file during during the compilation process.
These included files are usually header files. They're often used to define the physical layout of data, reusable  blocks of procedural code and/or forward declarations while promoting encapsulation. 

#DEFINE
Creates a macro, or substitution value which is invoked *only* at compile time.  The resultant 'defined' value can't be modified once the program has been compiled and is executing.

WHAT IS DECLARING 'something' ?
A declaration introduces one or more names into a program.

Declarations can occur more than once in a program. Therefore, classes, structures, enumerated types, and other user-defined types can be declared for each compilation unit (class,  module, function etc)

Declaration is a language construct that specifies the properties of an identifier: it declares what a word (identifier) "means".
Declarations are most commonly used for functions, variables, constants, and classes, but can also be used for other entities such as enumerations and type definitions.

Declarations may also serve as definitions.   There are many derivatives of definitions that relate to the context of a declared object.

DEFINITIONS specify what code or data the name describes. The compiler needs the definition in order to allocate storage space for the thing that is being declared.

WHAT IS INITIALISING 'something' ?
initialization is the assignment of an initial value for a data object or variable. The manner in which initialization is performed depends on the type, storage class, etc., of the object to be initialized.
Initialization is done either statically embedding the value at compile time, or else by assignment at run time.
Experienced responders have a nose for laziness, (they were beginners once)... expecting the poster to contribute to the learning experience.

Go Up