Is this correct action for the c compiler/preprocessor ??

Mike Trachtman mike at WISDOM.BITNET
Wed Oct 30 22:07:16 AEST 1985


Consider the folowing short program.

#define BAD_SEGMENT     29
#define ERROR(number)   printf("Error number %d\n",number);

main() {
        /* typically there would be here some condition test
        if (somthing)
        */

        ERROR(BAD_SEGMENT);
}

what should this program do ????


On the compilers I have tried it, (vax 4.2, Vms C, Sun 2.0),
it has output of:

Error BAD_SEGMENT 29

rather than

Error number 29

which I would have expected.

Is this correct ???

I would think that anything inside double quotes is protected
from any/all substitution, and that the preprocessor, would
not do the parameter replacement.

Mike

                                Mike Trachtman
My address:

        mike at wisdom                             (BITNET)
        mike%wisdom.bitnet at wiscvm.ARPA          (ARPA/CSNET)
        mike%wisdom.bitnet at berkley              (ARPA/CSNET)
and if all else fails (ONLY for VERY short items)
        ...!decvax!humus!wisdom!mike            (UUCP)



More information about the Comp.lang.c mailing list