Compile errors with basic jsapi integration

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Compile errors with basic jsapi integration

crdumoul
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'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.
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Compile errors with basic jsapi integration

Kent Williams
What version of clang?  What version of SpiderMonkey? I've tried a CLang
compile on Centos7 -- the free Red Hat 7 -- and run into these problems
or something similar.

I would think there should be a way to compile with Clang, as that's the
system compiler on OS X now.


On 02/25/2018 01:57 PM, [hidden email] 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'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.
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Compile errors with basic jsapi integration

Wes Garland
How did you compile spidermonkey itself?  That will yield important clues
about what compiler/flags/etc you need to use for your embedding.

Wes

On 26 February 2018 at 10:10, Kent Williams <[hidden email]> wrote:

> What version of clang?  What version of SpiderMonkey? I've tried a CLang
> compile on Centos7 -- the free Red Hat 7 -- and run into these problems or
> something similar.
>
> I would think there should be a way to compile with Clang, as that's the
> system compiler on OS X now.
>
>
>
> On 02/25/2018 01:57 PM, [hidden email] 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'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.
>> _______________________________________________
>> dev-tech-js-engine mailing list
>> [hidden email]
>> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>>
>
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>



--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Compile errors with basic jsapi integration

philip.chimento
In reply to this post by crdumoul
On Sunday, February 25, 2018 at 2:57:54 PM UTC-5, [hidden email] 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,
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine