Thread: struct declared in parameter list

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    93

    struct declared in parameter list

    Could anyone explain to me why...

    void send_struct(struct stuff *mystuff);

    would cause the following warning in gcc

    test.h:54: warning: \u2018struct stuff\u2019 declared inside parameter list
    test.h:54: warning: its scope is only this definition or declaration, which is probably not what you want
    test.h:55: warning: \u2018struct stuff\u2019 declared inside parameter list

    i have the method declared as shown above in both my .c and .h files.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    It sounds like you did not declare or define struct stuff before that line.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    93
    i have it defined in a header file

    #include "stuff.h"

    which is at the top of the header file with the issue. It is defined as:

    Code:
    struct stuff
    {
        int number;
        int number2;
    }
    in stuff.h

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Where is the terminating semi-colon in your struct definition?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    93
    There is a semi-colon. I just didnt paste it. My code compiles just fine, but I am always stuck with this warning. I really think this may be a bug with gcc. I have numerous other similar function calls with the same structure and they are not issued warnings.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by fguy817817
    There is a semi-colon. I just didnt paste it.
    Why didn't you paste it? You are wasting everyone's time, including your own, by posting code that is not actually what you are trying to compile.

    Quote Originally Posted by fguy817817
    My code compiles just fine, but I am always stuck with this warning. I really think this may be a bug with gcc. I have numerous other similar function calls with the same structure and they are not issued warnings.
    Post the smallest and simplest compilable program that demonstrates the warning.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. How can I traverse a huffman tree
    By carrja99 in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2003, 05:46 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM