Newbie question about structures and further documentation

Jonathan Pryor jonpryor@vt.edu
Mon May 31 21:10:00 GMT 1999


Posting sample code that you're having problems with would help.

However, I'm able to pass and return an entire structure on the
stack.

    /* st.c -- passing around structs.
     * to compile: gcc -o st st.c
     */

    #include <stdio.h>

    struct foo {
      int bar;
    };

    void by_value (struct foo f)
    {
      printf ("value of foo::bar: %i\n", f.bar);
    }

    void by_ptr (struct foo* pf)
    {
      printf ("value of foo::bar: %i\n", pf->bar );
    }

    struct foo ret_foo ()
    {
      struct foo f;
      f.bar = 42;
      return f;
    }

    int main ()
    {
      struct foo f;
      f = ret_foo ();
      by_value (f);
      by_ptr(&f);
      return 0;
    }

hth
 - Jon

-----Original Message-----
From: pbecker <pbecker@idirect.com>
To: Cygwin Sourceware <cygwin@sourceware.cygnus.com>
Date: Wednesday, May 26, 1999 2:51 AM
Subject: Newbie question about structures and further documentation


>I am a student at the DeVry Institute of Tech. I am just learning the
>C language. The compile of choice at school is Borland. This is not my
>choice. I prefer to use Cygwin and my Emacs editor.
>
>I have become aware of some incompatibilities between the two
>compilers. Problems, which my teacher cannot help me with because he
>is not familiar with this compiler.
>
>With regards to structures, my text book states that some  compilers
>cannot pass and return entire structures to a function. I seem to be
>unable to do this either. I seem to be unable to even pass a pointer
>to a struct.
>
>How does Cygwin deal with this differently? Where can I find docs that
>would be appropriate for someone like myself? I have been unable to
>extract any useful information from the documentation at the Cygwin
>site.
>
>Paul Becker
>
>
>--
>Want to unsubscribe from this list?
>Send a message to cygwin-unsubscribe@sourceware.cygnus.com
>


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list