Difference between revisions of "User talk:Kr/Parameterized Headers"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Parameterized Headers)
(No difference)

Revision as of 08:12, 30 March 2006

some thoughs about headers

HowTo Include C / C++ Headers

  • A header provides the interface to (parts) of zero or multiple libraries.
  • A header may includes other headers.
  • A header may be parameterizeable (parameters may be mandantory): Parameterizeable Headers A header is parameterizeable, if it reacts on defines.
  • A header inherits parameters from included headers.
Include headers in reverse order of Distance.

This ensures

  • that the compiler produces an error in case the header is not complete,
  • that successve (parameterizeable) headers are configured properly
Parameterize successive headers in the header and according to the headers code.

Examples

Matching header first
"mycode.hxx"

void testfun(void *);

"mycode.cxx" // include matching header first #include "mycode.hxx"
#include <anyotherheader.hxx>
Parameterize base header
"mycode.hxx"

#define PARAMETER_FOR_PARA_HEADER 27
#include <paraheader.hxx>
void testfun(void *)

"mycode.cxx"
#include <mycode.hxx> // even if (in)directly including "paraheader.hxx" again, it is parameterized correctly (which would not be true, if including it first) #include "paraheader.hxx" </code>
Parameterizeable header
<paraheader.hxx>

#if PARAMETER_FOR_PARA_HEADER == 27
  void testfun(int para = "dies");
#else
  void testfun(int para = "dass");
#endif

Inherit Header Parameters
<mycode.hxx>

#include <paraheader.hxx>
 <mycode.cxx>
   #include <mycode.hxx>
   void aFun() {
   }
Personal tools