delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/08/16/09:15:30

Message-ID: <3f3e2079$0$168$cc7c7865@news.luth.se>
From: Martin Str|mberg <ams AT speedy DOT ludd DOT luth DOT se>
Subject: as and structs
Newsgroups: comp.os.msdos.djgpp
User-Agent: tin/1.4.6-20020816 ("Aerials") (UNIX) (NetBSD/1.6Q (alpha))
Date: 16 Aug 2003 12:15:53 GMT
Lines: 101
NNTP-Posting-Host: speedy.ludd.luth.se
X-Trace: 1061036153 news.luth.se 168 130.240.16.13
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello.

Versions:
gcc 2.953
as and ld 2.12.1
make 3.79.1

I have a header file x.h:
#define DEBUG (1)

void print_world(void);

struct Y {
  int i;
  char *p;
};


This header file is #included in x.c:
#include <stdio.h>
#include "x.h"

int main(void)
{
  printf("Hello ");

  print_world();

  return 0;
}


and in y.S:
#include "x.h"

debug:          .byte DEBUG

world:  .asciz "world\n"


        .globl _print_world
_print_world:
        testb   $0xff, debug
        jz      .Lskip_print

        pushl   $world
        call    _printf
        addl    $4, %esp

.Lskip_print:
        ret


makefile is:
SHELL   = /bin/sh
CC      = gcc
CFLAGS  = -O2 -Wall

all: x

x: x.o y.o

x.o: x.h

y.o: x.h

clean:
        -rm *.o


make says:
cd k:/tmp/x/
make clean; make
rm *.o
gcc -O2 -Wall   -c -o x.o x.c
gcc    -c -o y.o y.S
t:\tmp\cc24z1S1.s: Assembler messages:
t:\tmp\cc24z1S1.s:5: Error: no such instruction: `void print_world(void)'
t:\tmp\cc24z1S1.s:7: Error: no such instruction: `struct Y{'
t:\tmp\cc24z1S1.s:8: Error: suffix or operands invalid for `int'
t:\tmp\cc24z1S1.s:9: Error: no such instruction: `char *p'
t:\tmp\cc24z1S1.s:10: Warning: rest of line ignored; first ignored character is `}'
make.exe: *** [y.o] Error 1

Compilation exited abnormally with code 2 at Sat Aug 16 14:03:27


If I remove the prototype and struct in x.h it works fine.


Questions:

1.  What should I do to make this work nicely with prototypes and
structs in header files?

2. Why is CFLAGS missing while compiling y.S


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019