I'm having trouble with the import statement and I'm hoping someone
can point out a solution.

I have many components in my system and I'd like each to have an
independent set of messages while still being able to reuse some
common messages.

So I have 2 files similar to the following:

//
-----------------------------------------------------------------------
// File: CommonMsgs.proto
option optimize_for = LITE_RUNTIME;

package Common;

message PbVariant
{
    enum DataType
    {
        DATATYPE_UNDEFINED = 0;
        DATATYPE_BOOL = 1;
        DATATYPE_INT32 = 2;
        DATATYPE_DOUBLE = 3;
        DATATYPE_STRING = 4;
        DATATYPE_NUM_ITEMS = 5;
    }
    required DataType type = 1 [default = DATATYPE_UNDEFINED];
    optional bool valueBool = 2;
    optional int32 valueInt32 = 3;
    optional double valueDouble = 4;
    optional string valueString = 5;
}
//
-----------------------------------------------------------------------

//
-----------------------------------------------------------------------
// File: SpecificMsgs.proto
import "CommonMsgs.proto"
option optimize_for = LITE_RUNTIME;

package Specific;

message PbTopic
{
        required string key = 1;
        required Common.PbVariant value = 2;
}
//
-----------------------------------------------------------------------

Each project is in a separate directory on the file system so I call
something like: "protoc -I pathSpecific -I pathCommon ..." this allows
protoc to find both files when it's run.  The trouble I have is that I
get a file like the following:

//
-----------------------------------------------------------------------
// File: SpecificMsgs.proto
...
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include "CommonMsgs.pb.h" // This line has a compile error as the
file cannot be found
...
//
-----------------------------------------------------------------------

To remedy the file not found issue I can add path info to the import
statement but that will trigger a different error.  The other error is
since the following function name will be changed to include the path:
before: ::Common::protobuf_AddDesc_CommonMsgs_2eproto();
after: ::Common::protobuf_AddDesc_Common_CommonMsgs_2eproto(); (or
something like this)

Any idea how I can solve this?

Thanks,
Jason

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to