|
From: | John W. Eaton |
Subject: | Re: strategy for .h files? |
Date: | Tue, 2 May 2017 17:59:32 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 |
On 05/02/2017 04:18 PM, Rik wrote:
Summarizing, Octave's aim is for lightweight header files. These should include the minimal number of #includes necessary for the header file itself to compile correctly (And can you add the test you used as a Makefile target?).
The test I used worked on the installed set of header files. I'll see if I can come up with something similar that can work in the build tree.
Even when a class is mentioned, consider whether a simple forward declaration of the class is sufficient rather than including a complete header file. As an example of the last point, many headers in the interpreter library have input or output arguments which are of type octave_value. Unless the header file does actual is type converting by calling "octave_value (xxx)", there is no need to '#include "ov.h"' when "class octave_value;" will do.
Yes, as long as it is just the declaration of return type and there is no inline code for the function that requires calling an actual constructor function.
I hesitate to use similar forward declarations for std:: objects since we don't control how they are declared. Sometimes using "namespace std { class FOO; }" might work, but a C++ implementation could do something different that would cause this type of forward declaration to fail.
jwe
[Prev in Thread] | Current Thread | [Next in Thread] |