tsoding / ray-tracer

My ongoing effort to learn how to make Ray Tracers
MIT License
15 stars 2 forks source link

17 errors generated #9

Closed TheKnarf closed 6 years ago

TheKnarf commented 6 years ago

Tried building the project on MacOS (without nix-shell):

make
g++ -ggdb -Wall -Werror -Wconversion -std=c++17 main.cpp -o ray-tracer
main.cpp:61:26: error: implicit conversion changes signedness: 'uint8_t'
      (aka 'unsigned char') to 'std::__1::basic_ostream<char,
      std::__1::char_traits<char> >::char_type' (aka 'char')
      [-Werror,-Wsign-conversion]
                fout.put(static_cast<uint8_t>(display[row * width + col].v[k]));
                     ~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:69:24: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
    vec3<float> dir = {0.0f, 0.0f, 1.0f};
                       ^~~~~~~~~~~~~~~~
                       {               }
main.cpp:70:39: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
    const vec3<float> sphereCenter = {0.0f, 0.0f, scene.sphereZ};
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~
                                      {                        }
main.cpp:71:24: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
    vec3<float> ray = {x, y, 0.0f};
                       ^~~~~~~~~~
                       {         }
main.cpp:89:13: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
    return {0U, 0U, 0U};
            ^~~~~~~~~~
            {         }
main.cpp:119:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 0, 0, -1, 500 },    // p
                      ^~~~~~~~~~~~~
                      {            }
main.cpp:120:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 255, 255, 255 }     // c
                      ^~~~~~~~~~~~~
                      {            }
main.cpp:123:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 0, 0, 1, 500 },    // p
                      ^~~~~~~~~~~~
                      {           }
main.cpp:124:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 255, 0, 0 }        // c
                      ^~~~~~~~~
                      {        }
main.cpp:127:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 1, 0, 0, 500 },    // p
                      ^~~~~~~~~~~~
                      {           }
main.cpp:128:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 0, 255, 0 }        // c
                      ^~~~~~~~~
                      {        }
main.cpp:131:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { -1, 0, 0, 500 },    // p
                      ^~~~~~~~~~~~~
                      {            }
main.cpp:132:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 0, 0, 255 }        // c
                      ^~~~~~~~~
                      {        }
main.cpp:135:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 0, 1, 0, 500 },    // p
                      ^~~~~~~~~~~~
                      {           }
main.cpp:136:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 255, 255, 0 }        // c
                      ^~~~~~~~~~~
                      {          }
main.cpp:139:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 0, -1, 0, 500 },    // p
                      ^~~~~~~~~~~~~
                      {            }
main.cpp:140:23: error: suggest braces around initialization of subobject
      [-Werror,-Wmissing-braces]
                    { 255, 0, 255 }        // c
                      ^~~~~~~~~~~
                      {          }
17 errors generated.
make: *** [ray-tracer] Error 1

Compiler version:

g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
TheKnarf commented 6 years ago

Without -wall the only error I get is:

✗ make
g++ -ggdb -Werror -Wconversion -std=c++17 main.cpp -o ray-tracer
main.cpp:61:26: error: implicit conversion changes signedness: 'uint8_t' (aka 'unsigned char') to 'std::__1::basic_ostream<char,
      std::__1::char_traits<char> >::char_type' (aka 'char') [-Werror,-Wsign-conversion]
                fout.put(static_cast<uint8_t>(display[row * width + col].v[k]));
                     ~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [ray-tracer] Error 1
TheKnarf commented 6 years ago

Pulling version ae5d8dcb73f57e985e7f356a30c6336fc7965ce0 and removing -wall fixes the build.

TheKnarf commented 6 years ago

Fixed in newest build.