255
edits
(→C++14) |
|||
Line 73: | Line 73: | ||
# The C++ wrappers for C headers (cstdlib, cassert, etc.) | # The C++ wrappers for C headers (cstdlib, cassert, etc.) | ||
# C++ standard library headers (iostream, list, map, etc.) | # C++ standard library headers (iostream, list, map, etc.) | ||
# Other library header files (glpk.h, curl.h, etc., should be protected by {{codeline|#if defined (HAVE_FOO_H)}} since they may be missing on the build system) | # Other library header files (glpk.h, curl.h, etc., should be protected by {{codeline|#if defined (HAVE_FOO_H)}} since they may be missing on the build system) | ||
# Octave's liboctave headers | # Octave's liboctave headers | ||
# Octave's libinterp headers | # Octave's libinterp headers | ||
# Octave's libgui headers | |||
Other POSIX headers (sys/types.h, unistd.h, etc., should not be included directly into Octave sources. For portability, use a wrapper function. Anything you need is probably already available as a wrapper around a function or header provided by gnulib. See the files in liboctave/wrappers. This is necessary because although gnulib is great for portability, it does not generally work well with C++. | |||
Similarly, Windows headers should not be included directly into Octave sources. Wrappers that provide the needed functionality in an OS-independent way should be used instead. This is almost always possible and there are many examples in the Octave sources. | |||
Each grouping of header files should be alphabetized unless there is some | Each grouping of header files should be alphabetized unless there is some | ||
specific reason to not do that. The only case where that is true is in | specific reason to not do that. The only case where that is true is in | ||
{{Path|oct-parse.in.yy}} and there is a comment in the file for that one. | {{Path|oct-parse.in.yy}} and there is a comment in the file for that one. | ||
There is a strict ordering of header files/libraries that must be followed. There are '''no exceptions''' to these rules: | |||
* The functions in liboctave/wrappers may only use headers and symbols from gnulib, standard libraries, or OS-dependent libraries. They '''must not''' use any headers or symbols from other parts of liboctave, libinterp, or libgui. | |||
* liboctave '''must not''' use any headers or symbols from libinterp or libgui. It must be fully functional without the interpreter or GUI. | |||
* libinterp '''must not''' use any headers or symbols from libgui. It must be fully functional without the GUI. | |||
Header files should not use any "#if defined (HAVE_FEATURE)" conditionals. This is not quite true yet, but we are almost there. '''No new conditionals may be added.''' | |||
== Other C++ features == | == Other C++ features == |