struct declared in parameter list

This is a discussion on struct declared in parameter list within the C Programming forums, part of the General Programming Boards category; Could anyone explain to me why... void send_struct(struct stuff *mystuff); would cause the following warning in gcc test.h:54: warning: \u2018struct ...

  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
    21,593
    It sounds like you did not declare or define struct stuff before that line.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    21,593
    Where is the terminating semi-colon in your struct definition?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    21,593
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21