microsoft / Chakra-Samples

Repository for Chakra JavaScript engine related samples.
MIT License
216 stars 84 forks source link

Building HelloWorld on Linux, type "byte" is not defined #36

Closed juliusl closed 8 years ago

juliusl commented 8 years ago

Building the Linux sample, while including the ChakraCore header file will complain about the type byte not being defined.

The workaround I found was to just define the type on top of sample.cpp before #include "ChakraCore.h" (The type can be defined as typedef unsigned char byte;)

Not really sure the best way to fix this permanently which is why I'm not posting the workaround as a PR. I noticed a todo in the source for ChakraCommon.h mentioning to reduce the usage of these types for better x-plat, I guess eventually that would fix this build issue?

Here is the compilation error I get on Ubuntu 16.04 --

juliusl@jlubuntu:~/Github/chakracore/crossplatform$ make BUILD_TYPE=Debug
g++ sample.cpp -Wall -lstdc++ -std=c++0x -I../lib/Jsrt -Wl,--whole-archive ../BuildLinux/Debug/lib/../pal/src/libChakra.Pal.a ../BuildLinux/Debug/lib/Common/Core/libChakra.Common.Core.a ../BuildLinux/Debug/lib/Jsrt/libChakra.Jsrt.a -Wl,--no-whole-archive -pthread -lm -ldl -licuuc -lunwind-x86_64 -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-declarations -Wno-unknown-warning-option -o sample.o
In file included from ../lib/Jsrt/ChakraCore.h:26:0,
                 from sample.cpp:6:
../lib/Jsrt/ChakraDebug.h:692:137: error: ‘byte’ does not name a type
     typedef void (CHAKRA_CALLBACK *JsTTDInitializeForWriteLogStreamCallback)(_In_ size_t uriByteLength, _In_reads_(uriByteLength) const byte* uriBytes);
                                                                                                                                         ^
../lib/Jsrt/ChakraDebug.h:708:139: error: ‘byte’ does not name a type
     typedef JsTTDStreamHandle (CHAKRA_CALLBACK *TTDOpenResourceStreamCallback)(_In_ size_t uriByteLength, _In_reads_(uriByteLength) const byte* uriBytes, _In_z_ const char* asciiResourceName, _In_ b
                                                                                                                                           ^
../lib/Jsrt/ChakraDebug.h:719:120: error: ‘byte’ has not been declared
     typedef bool (CHAKRA_CALLBACK *JsTTDReadBytesFromStreamCallback)(_In_ JsTTDStreamHandle handle, _Out_writes_(size) byte* buff, _In_ size_t size, _Out_ size_t* readCount);
                                                                                                                        ^
../lib/Jsrt/ChakraDebug.h:730:123: error: ‘byte’ does not name a type
     typedef bool (CHAKRA_CALLBACK *JsTTDWriteBytesToStreamCallback)(_In_ JsTTDStreamHandle handle, _In_reads_(size) const byte* buff, _In_ size_t size, _Out_ size_t* writtenCount);
                                                                                                                           ^
../lib/Jsrt/ChakraDebug.h:763:44: error: ‘byte’ does not name a type
             _In_reads_(infoUriCount) const byte* infoUri,
                                            ^
../lib/Jsrt/ChakraDebug.h:787:44: error: ‘byte’ does not name a type
             _In_reads_(infoUriCount) const byte* infoUri,
                                            ^
../lib/Jsrt/ChakraDebug.h:935:18: error: ‘byte’ has not been declared
             _In_ byte* initialModPos);
                  ^
../lib/Jsrt/ChakraDebug.h:945:18: warning: ‘JsTTDRawBufferAsyncModifyComplete’ initialized and declared ‘extern’
             _In_ byte* finalModPos);
                  ^
../lib/Jsrt/ChakraDebug.h:945:18: error: ‘byte’ was not declared in this scope
../lib/Jsrt/ChakraDebug.h:945:24: error: ‘finalModPos’ was not declared in this scope
             _In_ byte* finalModPos);
                        ^
cc1plus: warning: unrecognized command line option ‘-Wno-unknown-warning-option’
cc1plus: warning: unrecognized command line option ‘-Wno-c++11-compat-deprecated-writable-strings’
Makefile:34: recipe for target 'testmake' failed
make: *** [testmake] Error 1
obastemur commented 8 years ago

@juliusl Thanks for the details. https://github.com/Microsoft/ChakraCore/pull/1479 fixes this. Once it is merged, will update here.

juliusl commented 8 years ago

@obastemur Awesome, thanks!

obastemur commented 8 years ago

Microsoft/ChakraCore#1479 is merged. closing this one too