how to stop compilation using CC preprocessor

how to stop compilation using CC preprocessor

Post by TC She » Sun, 04 Nov 2001 04:02:04



Hello:
  On HP-UX aCC, the following piece of codes will halt compilation is
__TEST__ is not defined

  #if !defined (__TEST__)
  #error "__TEST__ is not defined"
  #endif

  However, on Sun 5.7 CC 5.2 compiler, it just generates a warning
message.  How to make it stop if __TEST__ is not defined?

thank you

tcs

 
 
 

how to stop compilation using CC preprocessor

Post by Joerg Schilli » Sun, 04 Nov 2001 05:09:06




Quote:>Hello:
>  On HP-UX aCC, the following piece of codes will halt compilation is
>__TEST__ is not defined

>  #if !defined (__TEST__)
>  #error "__TEST__ is not defined"
>  #endif

>  However, on Sun 5.7 CC 5.2 compiler, it just generates a warning
>message.  How to make it stop if __TEST__ is not defined?

I cannt believe this, but.... look at this  code from the cdrecord
source:

#if     defined(_BIT_FIELDS_LTOH)       /* Intel byteorder */
#elif   defined(_BIT_FIELDS_HTOL)       /* Motorola byteorder */
#else
/*
 * #error will not work for all compilers (e.g. sunos4)
 * The following line will abort compilation on all compilers
 * if none of the above is defines. And that's  what we want.
 */
error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
#endif

--



URL:  http://www.fokus.gmd.de/usr/schilling    ftp://ftp.fokus.gmd.de/pub/unix

 
 
 

1. compilation problem using CC for TCL

Hi,

I tried to extract out an example from a book "Tcl and Tk Toolkit" and
compile with the following command:

cc simple.c -ltcl -lm

But I recieved this error message:

/usr/bin/ld: cannot open -lm: No such file or directory
collect2: ld returned 1 exit status

/* this is the code that I extract from the book example

#include <stdio.h>
#include <stdlib.h>
#include <tcl.h>

main(int argc, char *argv[])
{
        Tcl_Interp *interp;
        int code;

        if (argc != 2)
        {
                fprintf(stderr, "wrong # arguments: ");
                fprintf(stderr, "should be \"%s filename\"\n", argv[0]);
                exit(1);
        }

        interp = Tcl_CreateInterp();
        code = Tcl_EvalFile(interp, argv[1]);
        if (*interp->result != 0)
        {
                printf("%s\n", interp->result);
        }
        if (code != TCL_OK)
        {
                exit(1);
        }
        exit(0);

Please advice what went wrong. Thanks

------------------  Posted via CNET Linux Help  ------------------
                    http://www.searchlinux.com

2. console spam

3. Compilation times using Sun CC 5.0

4. aligning Netscape windows

5. Forcing CC NOT to use its preprocessor...

6. Known Solaris and LDAP Problems

7. Preprocessor symbol set by CC

8. Mandrake 9

9. Sys V/BSD "ps" newbie g++ preprocessor conditional compilation?

10. Assembler and Conditional Compilation (C Preprocessor)

11. stop using and stop buying: Caldera, SuSE, turboLinux, and Conectiva

12. kernel compilation: pls send cc to me

13. C (gcc): Using pre-processor symbols (ifdef) inside of a string (sort of)