Skip to content

Provide some guidance about the order or #define and #include statements in cobj #9

@gprossliner

Description

@gprossliner

When implementing the cobj files for a project, some code was not generated, which was expected to be so. The problem was like:

//class.h
#include "header.h"
...
#define COBJ_INTERFACE_IMPLEMENTATION_MODE
#include "interface.h"
#undef COBJ_INTERFACE_IMPLEMENTATION_MODE

So far everything looks ok, but what if "interface.h" uses a include-guard, and "header.h" includes "interface.h"?:

// header.h
#ifndef _HEADER_H_
#define _HEADER_H_ 

#include "interface.h"

#endif
//interface.h
#ifndef _INTERFACE_H_
#define _INTERFACE_H_ 

#define COBJ_INTERFACE_NAME interface
...
#include "cobj-interface-generator.h"

#endif

The result is, that "interface.h" is included at a time, where COBJ_INTERFACE_IMPLEMENTATION_MODE is not defined. Although it's included again in class.h, this is not effective, since the include guard (#ifndef _INTERFACE_H_), prevents the header to be processed again.

This seems to be related to #8, but even if COBJ_INTERFACE_IMPLEMENTATION_MODE is changed to an automatic check, the order still matters.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions