Closed Laeeth closed 5 years ago
Implement it how?
When headers are included in a .dpp file, whatever translation unit is seen by clang is what what gets translated - there's nothing to implement since it's a #pragma to clang itself.
On the D side, importing a module twice is fine, but #including a header in two .dpp files is not recommended.
Without an example of what doesn't work and what was expected there's not much I can do.
Did you try the examples?
Singular
I'll try as_record.h from aerospike once I set up an Ubuntu box I can install the .deb to. I'm wondering what it could be - maybe that libclang, as opposed to the actual compiler, needs a command-line switch to enable #pragma once
.
You can just clone the repo source code. You don't need to actually run it and if you do then from source is fine also.
My guess is that problem might have gone away after I fixed forward declarations as I didn't see anything similar with Xenon so far.
I assumed the problem was pragma once because I didn't have time to look into it properly. But there was definitely a problem with multiple declarations.
Yes thinking about it the forward declaration fix does more than that. If you end up with a function or aggregate definition more than once it doesn't matter - only the proper aggregate definition and only one function prototype will be used. The former definitely and I think latter but didn't check yet.
This worked fine:
./d++ --include-path aerospike-client-c/src/include --include-path aerospike-client-c/modules/common/src/include aerospike.dpp
// aerospike.dpp
#include "aerospike/as_record.h"
void main() {
auto rec = as_record();
rec.gen = 42;
}
Not implementing this leads to errors when headers are included multiple times. Example is a bit convoluted. aerospike/as_record.h