Chic documentation
Houlder Technologies

Mailing list

Statement sections

A statement section is started by the string "//chic" when it occurs at the beginning of a line before a statement or a macro in namespace scope. The initial string must be followed by a space and then a destination string which is one of "hh", "ii", or "cc". The destination string indicates that the section should be put in the hh-file, the ii-file or the cc-file. If the rest of the line is empty, the section spans until the end of the next statement or macro. Here's a small example.

File MyFile.hic:
  //chic hh
  #include <fcntl.h>

  //chic ii
  class MyClass;

  namespace MySpace
    //chic cc
    using namespace SomeOtherSpace;

In the first section, the include directive is moved to the header file. In the second section the forward declaration is moved to the ii-file. The purpose of specifying such include directives and forward declarations is to direct Chic when it cannot find the correct dependencies.

The third section specifies that the using directive be put in the cc-file and not in the header file. In the cc-file it will be wrapped in the MySpace namespace.

Block sections

A block section is a section delimited by a pair of curly braces:

  //chic hh {

  #include <fcntl.h>
  #include <sys/hepp.h>
  class A
   // ..

  //chic hh }

Such sections do not nest and the destination strings of the opening and the closing section must match. The section is equivalent to specifying a statement section for each of the statements inside the block section.

Effects of sections

Apart from checking the syntactical correctness, the content of a section is ignored in the generation. The using directive in the section above would hence not influence look-up. Likewise, if a section contains a function or a variable, it would not be qualified.

Since the interior of the sections are ignored it is possible to let a hic-file consist of nothing but one section for each destination file. This would certainly be of limited use, but it shows that sections bridge the gap between conventional C++ and Chic. They are thus an important transition tool to be used until Chic covers the full C++ language.

When and why use sections?

Sections are primarily used to explicitly add an include directive or a forward declaration to the header or the ii-file. This is needed when: