function prototype without (void)

بواسطة Rogerup

Resident (39)

صورة Rogerup

27-03-2019, 21:38

I had problems here to compile a program with #include msx.h

msx.h does not declare the function prototypes that not receive arguments with (void), it declares ()

The modern compilers warn that, but the specific old compiler (z88dk old version) I am using does not warn that but generates an error in the compiled code.

So, if you are having some weird problem, can be that.

Complementing, my problem only occurs if the first function in msx.h is a function without arguments, only changing the order with other function solve the problem (or apparently solve), so this can cause another problem I'm not seeing, therefore I think better using (void) in all prototypes.


void func1() { }

extern void __LIB__ func2();        // not compile
// extern void __LIB__ func2(void);    // compile

int main()
    return 0;

ASM generated with error:

;* * * * *  Small-C/Plus z88dk * * * * *
;  Version: 20070909.1
;   Reconstructed for the z80 Module Assembler
;   Module compile time: Wed Mar 27 18:19:50 2019

    MODULE  test2.c

    INCLUDE "#z80_crt0.hdr"


    call    func1
    ld  hl,0    ;const

; --- Start of Static Variables ---

; --- Start of Scope Defns ---

    XDEF    func1
    LIB func2
    XDEF    _main

; --- End of Scope Defns ---

; --- End of Compilation ---

It removes the _ of func1 at call and XDEF

Login أوregister لوضع تعليقاتك

بواسطة Timmy

Master (187)

صورة Timmy

29-03-2019, 12:05

I have relayed this to the other forum and you can see the answer here:

In short, you should use the latest version. The very latest version -- this is the version they prefer -- is the nightly version. There is also a 'stable' version from this year, if I recall this correctly.

بواسطة Rogerup

Resident (39)

صورة Rogerup

29-03-2019, 15:05

Thanks, I tried to post directly there, but the forum is closed for new users.

I'm already using the new version of the sdcc and sccz80 compilers, but I posted the comment here for a few reasons:

1) Sometimes I compile my code in all compilers I have (about 20 from 8 to 64 bits, several operating systems), and the only that had a problem, I solved with "(void)", and I posted here to register, in case someone in future compiles my code using the compiler cited.

2) Someone could be using this compiler and having some problem.

3) Maybe this problem has not been SOLVED in new versions of the compiler, just MASKED (if they didn't know about this particular problem), so someone who works with the development of this compiler could see some hint in this message, to check the specific part.

4) The OLD version of compiler generates a smaller binary code (10% smaller). So if I'm reaching the memory limits it can be a solution.

Thanks again for the cross-post.

بواسطة dom

Supporter (3)

صورة dom

29-03-2019, 21:47

I thought I might as well sign up here! Thanks to Timmy for relaying initially.

There was a bit of a spam influx (3 accounts/messages in 10 minutes) earlier this week so I disabled registrations on and forgot to re-enable them. They're back now. It will happen again I'm sure, so if anyone wants to register, just drop me an email at dom@ and I'll re-enable.

Anyway, back to the thread. About 18 months ago the declaration parsing was totally rewritten so I'm pretty confident that it's not been masked.

I'm surprised that that an older version is generating smaller, yet still correct code. There's been a bit of carefully selected inlining but in the test case I use this has sped up the program by 30% and reduced the total size. It sounds like you've got an example where that's not the case so I'm really interested in it.

If you could share the source with me and the OLD z88dk version I can see try to figure out where the size regression is and address it.

بواسطة Rogerup

Resident (39)

صورة Rogerup

30-03-2019, 01:18

Hi dom,

What is your e-mail, so I can send you the code and explanation.