Cancelio( ) function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samael
    New Member
    • Feb 2008
    • 4

    Cancelio( ) function

    I'm trying to compile a C++ program and I'm getting the error:

    implicit declaration of function 'int CancelIo(...)'

    if it will help it's a program for using USB.

    If anyone has any ideas that would be great. Thanks.
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    That error means you're trying to use a function whose prototype the compiler doesn't recognize, so it assumes you're returning an integer. Since you are returning an int, you can /technically/ get away without #including or writing the prototype if you have dire speed or size requirements, but it's not recommended if you can possibly avoid it. Meaning 99.999999% of the time, just #include.

    To give you an example,
    [CODE=c]
    int main(int argc, char** argv){
    int a = atoi(argv[1]);
    return 0;
    }
    [/CODE]

    This gives the same warning because <cstdio> has not been #included, so the compiler doesn't recognize it, but it can generate calling code anyway since it assumes an integer return type. Luckily, atoi() returns an int, so you can get away with this, but you really shouldn't try. Like ever.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Originally posted by Laharl
      This gives the same warning because <cstdio> has not been #included, so the compiler doesn't recognize it, but it can generate calling code anyway since it assumes an integer return type.
      What C++ compiler does that?? Function prototypes are required in C++ for all functions except main(). Your C++ compil;er shoulod produce an error

      What you say may be true of C but not C++.

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        Originally posted by weaknessforcats
        What C++ compiler does that?? Function prototypes are required in C++ for all functions except main(). Your C++ compil;er shoulod produce an error

        What you say may be true of C but not C++.
        That's what I get for assuming C ~= C++ at too broad of a level...

        Comment

        Working...