x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Error C3861 (identifier not found) when including protocol buffers

When I #include "myprotobuf.pb.h" in any of my classes, I get the following error: "error C3861: 'check': identifier not found" in myproject.generated.cpp. Looking through the includes for protobuf, the only reference I find to a check function is in stubs/type_traits.h

It may be worth noting that I had to modify stubs/common.h in order to get it to compile with UE4. I added #include "AllowWindowsPlatformTypes.h" and #include "HideWindowsPlatformTypes.h" at the beginning and end of the file, just inside the include guards.

Has anyone dealt with this before?

Product Version: UE 4.8
Tags:
more ▼

asked Jun 12 '15 at 03:15 PM in C++ Programming

avatar image

anthony.deschamps
59 4 6 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I managed to fix this. In the stubs/type_traits.h file in protocol buffers, there is a line with #undef check (source on GitHub). Apparently check is #defined on Mac. I commented out the #undef and renamed check to check_UnrealFix. Everything seems to work now (on Windows; I can't speak to Mac).

more ▼

answered Jun 12 '15 at 03:39 PM

avatar image

anthony.deschamps
59 4 6 12

avatar image MaSe87 Jan 15 '16 at 01:24 PM

Can you please describe in more detail how you solved it.

My obersation as a UE4 rookie: It depends on if you include an UE4 header. If not, everything is fine to use protobuf.

I did the try with and without redifintion at the end of the file without success:

Line 77:

 #define check_UNREAL_FIX check // temp variable
 #undef check

Line 365:

 // fix for unreal engine at the bottom of stubs/type_traits.h
 #define check check_UNREAL_FIX

avatar image anthony.deschamps Jan 15 '16 at 03:06 PM

The issue is that UE4 uses a macro called check (It's in AssertionMacros.h), and protobuf uses check as the name of a function (in type_traits.h). This would be an error already, although it would probably be easier to spot if protobuf didn't #undef it first. They #undef it because check is already #defined in Apple's Carbon API.

Luckily, protobuf's usage of check is quite small. You`ll need to rename check to something unique (like check_UnrealFix) in the is_base_of struct, starting on line 71:

 template<typename B, typename D>
 struct is_base_of {
   typedef char (&yes)[1];
   typedef char (&no)[2];

   // BEGIN GOOGLE LOCAL MODIFICATION -- check is a #define on Mac.
   // #undef check                                                            // COMMENT OUT
   // END GOOGLE LOCAL MODIFICATION

   static yes check(const B*);                                                // HERE
   static no check(const void*);                                              // HERE

   enum {
     value = sizeof(check(static_cast<const D*>(NULL))) == sizeof(yes),       // HERE
   };
 };

Also, you shouldn't #undef check at the bottom, because UE4 has probably already #defined it at the point where type_traits.h gets included, and you don't want to wipe that out.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Encountered the same problem, managed to compile by redefining the macro found in AssertionMacros.h (thanks anthony.deschamps) immediately after any includes of protobuf.

As of right now, the macro is defined as: #define check(expr) { if(!(expr)) { FDebug::LogAssertFailedMessage( #expr, _FILE, _LINE ); DebugBreakAndPromptForRemote(); FDebug::AssertFailed( #expr, _FILE, _LINE_ ); CA_ASSUME(expr); } }

more ▼

answered Mar 14 '16 at 01:07 AM

avatar image

Smerom
31 1 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question