[z88dk-dev] zcc_opt.def pragmas

Bridge to the z88dk-developers mailing list
Post Reply
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

[z88dk-dev] zcc_opt.def pragmas

Post by alvin »

I'm wondering if there is a reason a pragma is not defined as zero if it is set to zero:

void write_zcc_defined(char *name, int value)
{
add_zccopt("\nIF !DEFINED_%s\n",name);
add_zccopt("\tdefc\tDEFINED_%s = 1\n",name);
if (value) add_zccopt("\tdefc %s = %d\n",name,value);
add_zccopt("ENDIF\n\n");
}


I'm putting this into the C source:

#pragma output REGISTER_SP = -1 // set to 0 (top of memory)

#pragma output CRT_ENABLE_RESTART = 1 // not returning to basic
#pragma output CRT_ENABLE_CLOSE = 0 // do not close files on exit

#pragma output CLIB_EXIT_STACK_SIZE = 0 // no exit stack

#pragma output CLIB_MALLOC_HEAP_SIZE = 0 // no heap
#pragma output CLIB_STDIO_HEAP_SIZE = 0 // no stdio heap for files

#pragma output CLIB_FOPEN_MAX = 0 // no allocated FILE structures
#pragma output CLIB_OPEN_MAX = 0 // no fd table

and the 0 pragmas do not get written to the zcc_opt.def file:


IF !DEFINED_CLIB_MALLOC_HEAP_SIZE
defc DEFINED_CLIB_MALLOC_HEAP_SIZE = 1
ENDIF


IF !DEFINED_CLIB_STDIO_HEAP_SIZE
defc DEFINED_CLIB_STDIO_HEAP_SIZE = 1
ENDIF


IF !DEFINED_CLIB_FOPEN_MAX
defc DEFINED_CLIB_FOPEN_MAX = 1
ENDIF

etc.


They're marked as defined but do not get a defc set to zero. This does work because an undefined defc is 0 by default but it's interfering with some valid 0 pragmas I'm using in the new clib. So I'm wondering if it's ok to get zcc to write the 0 defcs?



------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
User avatar
dom
Well known member
Posts: 2091
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

On Tue, 6 Jan 2015, alvin (alvin_albrecht@...) wrote:
I'm wondering if there is a reason a pragma is not defined as zero if it is set to zero:

void write_zcc_defined(char *name, int value)
{
add_zccopt("\nIF !DEFINED_%s\n",name);
add_zccopt("\tdefc\tDEFINED_%s = 1\n",name);
if (value) add_zccopt("\tdefc %s = %d\n",name,value);
add_zccopt("ENDIF\n\n");
}
No reason that I can remember! Feel free to change it.

You'll need to change it in 3 places though:

sccz80/main.c::WriteDefined()
zcc/zcc.c::write_zcc_defined()
scanner/scanner.c::write_defined()



------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
Post Reply