1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Dismiss Notice

Bennugd Void * Issues As Type Members And Function Return Types

Discussion in 'Div / Fenix / BennuGD Zone' started by sam fisher, May 22, 2012.

  1. sam fisher

    sam fisher Well-Known Member

    Joined:
    Apr 11, 2004
    Messages:
    9,446
    Location:
    Bristol, UK
    I've recently started looking at BennuGD and got to the point where it would be convenient to have a linked list. So, I've tried to implement a generic linked list using void * for the stored items but this has led to a couple of issues.

    Firstly, I couldn't get the code to compile with a type containing a void * element but I managed to work around this by first defining a type containing nothing by a void element. I have no idea why this worked and since the compiler error was a syntax / parsing error I can think of no good reason why this should work :S.

    Secondly, I have not managed to successfully compile code that contains a function that returns a void * and I've tried an analogous work around to the above, defining a function returning type void, but that didn't work. Currently I'm working around this by returning an int * and doing some nasty type cast mangling but I don't think I should need to do this.

    Has anyone else run into similar issues to these?
     
    Tags:
  2. Abaddon666

    Abaddon666 Still Fresh

    Joined:
    Sep 28, 2007
    Messages:
    85
    Which compiler are you using? I compiled a small example with gcc 4.7.2 and had no issues:
    Code:
    class CTest
    {
    public:
      CTest()
      : m_number(0),
        m_pointer(0)
      {}
     
    private:
      int m_number;
      void* m_pointer;
    };
    
    void* MyFun(int i)
    {
      return 0;
    }
    
    int main (int argc, char* argv[])
    {
      CTest myTest;
      MyFun(0);
      return 0;
    }
    
    Can you give a minimum example that doesn't work for you?
     

Share This Page

Loading...