-2

I'm using a stack that defines these type labels and functions:

typedef const char * FONAFlashStringPtr;
typedef uint8 boolean; // uint8 is replaced with unsigned char

void HTTP_para_start(FONAFlashStringPtr parameter, boolean quoted = true);

when calling the function I use a FONAFlashStringPtr and true/false, which are defines for 1 and 0, but I get this output:

'HTTP_para_start' is ambiguous ' Candidates are: void HTTP_para_start(const char *, unsigned char)

Can't get why it's failling, they are the same type. Shouldn't the compiler travel through the type labels?

EDIT

It ended up being a Eclipse bug, Project -> Clean didn't solved it but workspace restart did.

rnunes
  • 2,785
  • 7
  • 28
  • 56

1 Answers1

1

HTTP_para_start is also declared elsewhere, with a slightly different signature. You have two declarations, not just one. Thus you're not showing the entirety of your code, nor are you showing all of the errors: your question is deficient. An ambiguous call will list two or more candidates, not just one.

For example, the following fails with the same error:

typedef const char * FONAFlashStringPtr;
typedef unsigned char boolean; // uint8 is replaced with unsigned char

void HTTP_para_start(FONAFlashStringPtr parameter, boolean quoted = true) {}
void HTTP_para_start(FONAFlashStringPtr parameter, bool quoted = true) {}

int main() {
   HTTP_para_start("", 1); // you say you define true to be 1
}

Generally speaking, since you write C++, not C, it's doesn't make sense to create additional boolean-like types. C++ got bool, use it. And don't define macros that shadow built-in keywords (see this answer for reference).

At the very least, your macros for true and false are incorrect: they are integers, not unsigned chars! If this was C, you could have:

#define true ((unsigned char)1)
#define false ((unsigned char)0)
Community
  • 1
  • 1
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313