Skip to content

TGAColor expects an array and not integer arguments #142

Closed
@tsadarsh

Description

@tsadarsh

Compiling my mesh.cpp throws the following error in at this line:

const TGAColor white = TGAColor(255, 255, 255, 255);
 error: no matching function for call to ‘TGAColor::TGAColor(int, int, int, int)’
    6 | const TGAColor white = TGAColor(255, 255, 255, 255);
tgaimage.h:23:8: note: candidate: ‘constexpr TGAColor::TGAColor()’
   23 | struct TGAColor {
      |        ^~~~~~~~
tgaimage.h:23:8: note:   candidate expects 0 arguments, 4 provided
tgaimage.h:23:8: note: candidate: ‘constexpr TGAColor::TGAColor(const TGAColor&)’
tgaimage.h:23:8: note:   candidate expects 1 argument, 4 provided
tgaimage.h:23:8: note: candidate: ‘constexpr TGAColor::TGAColor(TGAColor&&)’
tgaimage.h:23:8: note:   candidate expects 1 argument, 4 provided

Going through the definition of TGAColor in tgaimage.h it is very clear that it expects an array:

struct TGAColor {
    std::uint8_t bgra[4] = {0,0,0,0};
    std::uint8_t bytespp = 4;
    std::uint8_t& operator[](const int i) { return bgra[i]; }
};

So shouldn't TGAColor(255, 255, 255, 255); be changed to TGAColor({255, 255, 255, 255}); in the Wiki pages too?

Doing so compiles the program successfully without any errors. Is this an actual bug or am I not understanding something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions