Thread: Local function definitions are illegal!?

  1. #1
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    Local function definitions are illegal!?

    Ok, this makes no sense. I have this function for example:

    void func1(int, int); //prototype

    void func1(int y, int z)
    { //This is the line of the error
    blah blah, all this stuff
    }

    What the heck does that mean?

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It probably means you've tried to define your function from within another function. Function definitions either need to be global or inlined in class declarations.
    zen

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    7
    This error crops up as the answer to missing closing curly braces (}). Usually the function that is causing the error is not intended to be defined locally (i.e. inside another function) ... the problem typically lies in the previous function which forgets a closing curly brace somewhere. The following would cause this error:

    void func1(int a)
    {
    if (a > 10)
    {
    cout << "a > 10" << endl;
    }

    void func2(int b)
    { // will get error here

    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  5. local function definitions are illegal
    By curlious in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2003, 04:09 AM