Missing #ENDIF is not warned by the compiler

73 views
Skip to first unread message

Hurricane

unread,
Sep 19, 2025, 12:55:13 AM (10 days ago) Sep 19
to Harbour Developers, Harbour Users
A small detail that Harbour ignores when compiling

#include 'hbclass.ch'
#include 'error.ch'
#include 'common.ch'

#ifndef _PRJ_CH_
#define _PRJ_CH_

#define DEF1             0
#define DEF2             2
#define DEF3             3

This code in the CH file will compile normally. It's strange that Harbour doesn't warn about it (even clipper behaves the same way).
If for any reason the PRG file invokes CH multiple times, then compilation will fail (due to the lack of #ENDIF).



I discovered it by chance recently when I was called to help a user on an open source project. I saw the CH file I created 5 years ago, and days later someone added more lines and removed the #ENDIF.

Regards,
Hurricane

Przemyslaw Czerpak

unread,
Sep 19, 2025, 7:41:19 AM (9 days ago) Sep 19
to 'Hurricane' via Harbour Developers
Hi,

It's replicated Clipper behavior just like multiple #else, i.e.

```
#define _FOO_
#ifdef _FOO_
    #stdout defined
#else
    #stdout undefined
#else
    #stdout else 2
#else
    #stdout else 3
#eslse
    #stdout else 4
```

best regards,
Przemek

W dniu 19.09.2025 o 06:54, 'Hurricane' via Harbour Developers pisze:
--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-devel/1335606801.2665446.1758257670004%40mail.yahoo.com.

Reply all
Reply to author
Forward
0 new messages