Skip to content

Warnings during compile for v0.2.7 #87

Closed

Description

@hajapy

I was updating the conda-forge feedstock to 0.2.7 and noticed the following warnings in the builds for linux and os x. Full logs here:
https://circleci.com/gh/conda-forge/python-rapidjson-feedstock/tree/pull%2F6
https://travis-ci.org/conda-forge/python-rapidjson-feedstock/builds/314361977

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
./rapidjson.cpp:1145:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 };
 ^
./rapidjson.cpp:1145:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:1145:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:1145:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:1145:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:1145:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:1145:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:1145:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 };
 ^
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:2250:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
./rapidjson.cpp:1136:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"datetime_mode",

     ^

./rapidjson.cpp:1137:63: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(DecoderObject, datetimeMode), READONLY, "datetime_mode"},

                                                              ^

./rapidjson.cpp:1138:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"uuid_mode",

     ^

./rapidjson.cpp:1139:59: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(DecoderObject, uuidMode), READONLY, "uuid_mode"},

                                                          ^

./rapidjson.cpp:1140:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"number_mode",

     ^

./rapidjson.cpp:1141:61: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(DecoderObject, numberMode), READONLY, "number_mode"},

                                                            ^

./rapidjson.cpp:1142:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"parse_mode",

     ^

./rapidjson.cpp:1143:60: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(DecoderObject, parseMode), READONLY, "parse_mode"},

                                                           ^

./rapidjson.cpp:2233:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"skip_invalid_keys",

     ^

./rapidjson.cpp:2234:66: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_BOOL, offsetof(EncoderObject, skipInvalidKeys), READONLY, "skip_invalid_keys"},

                                                                 ^

./rapidjson.cpp:2235:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"ensure_ascii",

     ^

./rapidjson.cpp:2236:62: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_BOOL, offsetof(EncoderObject, ensureAscii), READONLY, "ensure_ascii"},

                                                             ^

./rapidjson.cpp:2237:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"indent",

     ^

./rapidjson.cpp:2238:57: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(EncoderObject, indent), READONLY, "indent"},

                                                        ^

./rapidjson.cpp:2239:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"sort_keys",

     ^

./rapidjson.cpp:2240:62: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_BOOL, offsetof(EncoderObject, ensureAscii), READONLY, "sort_keys"},

                                                             ^

./rapidjson.cpp:2241:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"max_recursion_depth",

     ^

./rapidjson.cpp:2242:68: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(EncoderObject, maxRecursionDepth), READONLY, "max_recursion_depth"},

                                                                   ^

./rapidjson.cpp:2243:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"datetime_mode",

     ^

./rapidjson.cpp:2244:63: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(EncoderObject, datetimeMode), READONLY, "datetime_mode"},

                                                              ^

./rapidjson.cpp:2245:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"uuid_mode",

     ^

./rapidjson.cpp:2246:59: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(EncoderObject, uuidMode), READONLY, "uuid_mode"},

                                                          ^

./rapidjson.cpp:2247:6: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

    {"number_mode",

     ^

./rapidjson.cpp:2248:61: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]

     T_UINT, offsetof(EncoderObject, numberMode), READONLY, "number_mode"},

                                                            ^

24 warnings generated.

Activity

  1. changed the title [-]Warnings during compile in linux[/-] [+]Warnings during compile for v0.2.7[/+] on Dec 10, 2017
  2. hajapy commented on Dec 10, 2017

    @hajapy
    Author

    Oh also for windows:

    ./rapidjson.cpp(1854): warning C4244: '=': conversion from 'double' to 'int', possible loss of data
    ./rapidjson.cpp(2309): note: see reference to function template instantiation 'PyObject *dumps_internal<rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::ASCII<char>,rapidjson::CrtAllocator>,rapidjson::UTF8<char>,rapidjson::ASCII<char>,rapidjson::CrtAllocator,0>,rapidjson::GenericStringBuffer<rapidjson::ASCII<char>,rapidjson::CrtAllocator>>(WriterT *,BufferT *,PyObject *,bool,PyObject *,bool,unsigned int,NumberMode,DatetimeMode,UuidMode)' being compiled
            with
            [
                WriterT=rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::ASCII<char>,rapidjson::CrtAllocator>,rapidjson::UTF8<char>,rapidjson::ASCII<char>,rapidjson::CrtAllocator,0>,
                BufferT=rapidjson::GenericStringBuffer<rapidjson::ASCII<char>,rapidjson::CrtAllocator>
            ]
    ./rapidjson.cpp(1938): warning C4244: 'argument': conversion from 'double' to 'int64_t', possible loss of data
    ./rapidjson.cpp(2004): warning C4244: 'argument': conversion from 'double' to 'int64_t', possible loss of data
    

    https://ci.appveyor.com/project/conda-forge/python-rapidjson-feedstock/build/1.0.7/job/j9kbi9ys65v8dptc#L389

  3. lelit commented on Dec 10, 2017

    @lelit
    Contributor

    AFAICT the warnings about the constant strings are not avoidable (but starting with 3.6 more and more of those structs are defined with const char *).
    The others, related to implicit conversion from double to int may be mitigated with an explicit cast, but should be otherwise safe.

  4. hajapy commented on Dec 10, 2017

    @hajapy
    Author

    Could the string literals in the structs be cast as (char *)"string_literal"?

  5. lelit commented on Dec 14, 2017

    @lelit
    Contributor

    I tried in the past, but coercing string literals to char* caused a different kind of warning, at least on GNU C++: that's why setup.py adds a -Wno-write-strings option when it detects that compiler chain.

    I added some explicit casts in commit fb355a0, can you please try latest master and tell me if that helps wrt the second set of warnings.

  6. lelit commented on Dec 20, 2017

    @lelit
    Contributor

    I just released v0.3 and I'd be curious to know whether the mentioned changes ameliorated the Windows build.

  7. hajapy commented on Dec 20, 2017

    @hajapy
    Author

    Ok, trying here: conda-forge/python-rapidjson-feedstock#7

    For future reference, you can fork the feedstock and change the recipe to use a git sha instead of a package off pypi if you want to test things before tagging a release.

  8. hajapy commented on Dec 20, 2017

    @hajapy
    Author

    seeing this on the windows x64 builds

    ./rapidjson.cpp(1317): warning C4267: 'initializing': conversion from 'size_t' to 'rapidjson::SizeType', possible loss of data
    ./rapidjson.cpp(1668): warning C4244: 'argument': conversion from 'Py_ssize_t' to 'rapidjson::SizeType', possible loss of data
    ./rapidjson.cpp(2339): note: see reference to function template instantiation 'bool dumps_internal<rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::ASCII<char>,rapidjson::CrtAllocator>,rapidjson::UTF8<char>,rapidjson::ASCII<char>,rapidjson::CrtAllocator,0>>(WriterT *,PyObject *,bool,PyObject *,bool,NumberMode,DatetimeMode,UuidMode)' being compiled
            with
            [
                WriterT=rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::ASCII<char>,rapidjson::CrtAllocator>,rapidjson::UTF8<char>,rapidjson::ASCII<char>,rapidjson::CrtAllocator,0>
            ]
    ./rapidjson.cpp(1675): warning C4244: 'argument': conversion from 'Py_ssize_t' to 'rapidjson::SizeType', possible loss of data
    ./rapidjson.cpp(1725): warning C4244: 'argument': conversion from 'Py_ssize_t' to 'rapidjson::SizeType', possible loss of data
    ./rapidjson.cpp(1758): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
    ./rapidjson.cpp(1759): warning C4244: 'argument': conversion from 'Py_ssize_t' to 'rapidjson::SizeType', possible loss of data
    ./rapidjson.cpp(2034): warning C4244: 'argument': conversion from 'Py_ssize_t' to 'rapidjson::SizeType', possible loss of data
    
  9. lelit commented on Dec 20, 2017

    @lelit
    Contributor

    Thank you, will take a look!

  10. lelit commented on Dec 20, 2017

    @lelit
    Contributor

    @hajapy, I pushed a couple of commits in https://github.com/lelit/python-rapidjson/tree/issue87: it would be nice if you could give that a try...
    I'm sorry, but I do not have any WinXX machine around me (yeah, I'm a lucky boy ;-) so I'd really appreciate some help on that.

  11. hajapy commented on Dec 20, 2017

    @hajapy
    Author

    I'm trying here:
    conda-forge/python-rapidjson-feedstock@master...hajapy:lelit2
    https://ci.appveyor.com/project/hajapy/python-rapidjson-feedstock

    I also do not have a local windows machine for testing. I am my fork of the conda-forge feedstock and enabled that as a build project on appveyor, so I can get it to test the recipe for me. I can help guide you to setting this up for yourself if you want to be able to do the same in the future.

  12. lelit commented on Dec 20, 2017

    @lelit
    Contributor

    Oh, I completely misunderstood your hint then :)
    Thank you, I will try that myself, but I'm afraid after xmas...

  13. hajapy commented on Dec 20, 2017

    @hajapy
    Author

    only warnings remaining in the x64 builds (note: I did not do mac/linux builds)

    rapidjson.obj : warning LNK4197: export 'PyInit_rapidjson' specified multiple times; using first specification
       Creating library build\temp.win-amd64-3.6\Release\.\rapidjson.cp36-win_amd64.lib and object build\temp.win-amd64-3.6\Release\.\rapidjson.cp36-win_amd64.exp
    
  14. lelit commented on Dec 21, 2017

    @lelit
    Contributor

    Good, thanks!

    I don't know how to deal with that warning, maybe its something done internally by the build (distutils?) process, as I do not explicitly create that .exp file.

  15. lelit commented on Dec 21, 2017

    @lelit
    Contributor

    I released v0.3.2 with the mentioned fixes. Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions