dropbox / djinni

A tool for generating cross-language type declarations and interface bindings.
Apache License 2.0
2.88k stars 488 forks source link

Use additional C++ include directories #395

Open Isko97 opened 5 years ago

Isko97 commented 5 years ago

I have a simple question, is it possible to use additional C++ include directories and to write include statements like #include <mylib/file.hpp>

paulocoutinhox commented 5 years ago

Hi,

You want include line "#include <mylib/file.hpp>" into djinni generated header files?

Or you want add a prefix into djinni generated header files?

Ty.

artwyman commented 5 years ago

Not sure what you mean by additional include directories precisely.

There are command-line arguments which can let you add a configurable prefix to includes of various types of files. For instance cpp-include-prefix defined here: https://github.com/dropbox/djinni/blob/master/src/source/Main.scala#L130

Djinni always writes includes in quotes like "foo.hpp" not angle-brackets like <foo.hpp> so if that's a distinction you were trying to make it's not something Djinni can do out of the box.

Isko97 commented 5 years ago

I use gRPC as a transport protocol in my project which I want to implement in C++. Since the generated gRPC C++ source files are in a different directory than the C++ implementation of my app, I need to add the path to these files to the project to allow writing such include statements. So in the implementation of my djinni generated C++ classes I need to access the gRPC source files and to write #include <grpc/grpc.h> Excuse me for not enunciating me correctly and I hope I could do it properly.

paulocoutinhox commented 5 years ago

You dont have problems about include it in your implementation. In your .cpp file (implementation file) include your files:

#include "MyDjinniClass.hpp"
#include <grpcpp/grpcpp.h>

void MyDjinniClass::method() {
    // example
}