Jump to content

GCC Debugging/g++/Warnings

From Wikibooks, open books for an open world

friend declaration 'FUNCTION' declares a non-template function

[edit | edit source]
  • Message found in GCC version 4.5.1
  • usually paired with message:
note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here)
template <typename T>
class Foo {
public:
   T data;
   friend void Bar(Foo<T> &);
};

template <typename T> void Bar(Foo<T> &f) {
   cout << f.data << endl;
}

Possible fix?

template <typename TT> void Bar(TT &);

template <typename T>
class Foo {
public:
   T data;
   friend void Bar<>(Foo<T> &);
};

template <typename TT> void Bar(TT &f) {
   cout << f.data << endl;
}

ISO C++ says that these are ambiguous

[edit | edit source]

ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second

  • Message found in GCC versions ?
  • possibly a custom defined type cast is interfering with another cast inside a class definition

multi-character character constant

[edit | edit source]
  • Message found in GCC versions 4.4.3, 4.5.1
  • sometimes paired with the warning: "overflow in implicit constant conversion"
  • possibly from using a forward slash instead of a backslash in a character assignment.
char mrChar = '/0';  // instead of: char mrChar = '\0';

null argument where non-null required

[edit | edit source]
  • Message found in GCC versions ?
  • you're passing a null argument to a string function
strcpy(mrChar, '\0'); // won't work, null argument ('\0') supplied
strcpy(mrChar, ""); // will work?