Re: Compile errors with basic jsapi integration

[email protected] Tue, 15 May 2018 19:10:17 -0700 (PDT)
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
On Sunday, February 25, 2018 at 2:57:54 PM UTC-5, [email protected] wrote:
> I'm trying to build a basic hello world style program with JSAPI. I've copied the "boilerplate code necessary for a minimal JSAPI application" from the JSAPI User Guide (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_User_Guide) and I'm trying to build on OS X with the following command:
> 
> clang++  -std=c++11 -Iinclude -Llib  ew-test.cpp  -lmozjs-60a1 -lz -o ew-test

I've found that since mozjs-60 you need to use C++14. That cleared up these errors for me. I was using "Apple LLVM version 9.1.0 (clang-902.0.39.1)" according to "clang --version".

> I'm getting a bunch of compile errors. The output up to the first error is:
> In file included from ew-test.cpp:1:
> In file included from include/jsapi.h:15:
> In file included from include/mozilla/Range.h:12:
> include/mozilla/Span.h:194:3: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
>   operator=(const span_iterator<Span, IsConst>&) = default;
>   ^
>                                                  const
> include/mozilla/Span.h:208:47: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
>   MOZ_SPAN_NON_CONST_CONSTEXPR span_iterator& operator++()
>                                               ^
>                                                            const
> include/mozilla/Span.h:215:27: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
>   constexpr span_iterator operator++(int)
>                           ^
>                                           const
> include/mozilla/Span.h:222:47: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
>   MOZ_SPAN_NON_CONST_CONSTEXPR span_iterator& operator--()
>                                               ^
>                                                            const
> include/mozilla/Span.h:229:27: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
>   constexpr span_iterator operator--(int)
>                           ^
>                                           const
> include/mozilla/Span.h:243:41: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
>   MOZ_SPAN_GCC_CONSTEXPR span_iterator& operator+=(difference_type n)
>                                         ^
>                                                                       const
> include/mozilla/Span.h:258:28: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
>   constexpr span_iterator& operator-=(difference_type n)
>                            ^
>                                                          const
> include/mozilla/Span.h:183:5: error: statement not allowed in constexpr constructor
>     MOZ_RELEASE_ASSERT(span == nullptr ||
>     ^
> include/mozilla/Assertions.h:453:5: note: expanded from macro 'MOZ_RELEASE_ASSERT'
>     MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_ASSERT_HELPER, __VA_ARGS__), \
>     ^
> include/mozilla/MacroArgs.h:76:5: note: expanded from macro 'MOZ_PASTE_PREFIX_AND_ARG_COUNT'
>     MOZ_CONCAT, (aPrefix, MOZ_ARG_COUNT(__VA_ARGS__)))
>     ^
> 
> I can't figure out where I'm going wrong. Any help would be appreciated.

Regards,