Re: C as assembly language

jthorn@galileo.thp.univie.ac.at (Jonathan Thornburg)
13 May 2001 01:15:30 -0400

          From comp.compilers

Related articles
[12 earlier articles]
Re: C as assembly language rhyde@transdimension.com (Randall Hyde) (2001-04-14)
Re: C as assembly language vbdis@aol.com (2001-04-15)
Re: C as assembly language jim.granville@designtools.co.nz (Jim Granville) (2001-04-18)
Re: C as assembly language joachim_d@gmx.de (Joachim Durchholz) (2001-05-03)
Re: C as assembly language joachim_d@gmx.de (Joachim Durchholz) (2001-05-07)
Re: C as assembly language Hans_Boehm@hp.com (Hans Boehm) (2001-05-07)
Re: C as assembly language jthorn@galileo.thp.univie.ac.at (2001-05-13)
Re: C as assembly language david.thompson1@worldnet.att.net (David Thompson) (2001-05-15)
Re: C as assembly language thp@cs.ucr.edu (2002-03-31)
| List of all articles for this month |

From: jthorn@galileo.thp.univie.ac.at (Jonathan Thornburg)
Newsgroups: comp.compilers
Date: 13 May 2001 01:15:30 -0400
Organization: Universitaet Wien (Vienna, Austria) / Institut fuer Theoretische Physik
References: 01-03-006 01-04-027 01-04-052 01-05-021
Summary: structure assignment was already in K&R Classic
Keywords: C
Posted-Date: 13 May 2001 01:15:29 EDT

Joachim Durchholz <joachim.durchholz@gmx.de> wrote:
[[if a C function retunrs a struct]]
>3) What should the caller do with a struct from a result? You can't
                                                                                                                      =========
>assign it to another struct in C.
  =================================


You can't??? I was under the impression that structure assignment was
already present even in K&R Classic. And gcc 2.95.2 -Wall -pedantic
has no qualms with a test program:


#include <stdio.h>
struct foo { int x, y; };
struct foo fn(int i, int j, int k);
int main(void)
{
struct foo result;
result = fn(3,1,4);
printf("result.x=%d result.y=%d\n", result.x, result.y);
return 0;
}
struct foo fn(int i, int j, int k)
{
struct foo s;
s.x = i+j+k;
s.y = i*j*k;
return s;
}


--
-- Jonathan Thornburg <jthorn@thp.univie.ac.at>
      http://www.thp.univie.ac.at/~jthorn/home.html
      Universitaet Wien (Vienna, Austria) / Institut fuer Theoretische Physik


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.