Original message bounced, reposted.

Date: Thu, 11 Oct 2012 19:46:53 -0400
Subject: LIBBCC.H header bugfix for C++

Hi,

The following patch would correct a few "undefined" symbols if libbcc.h is used in a C++ program.

Specifically, if a macro is cancelled for a BGI call (like, line() called as a regular function) or a special-case, macro-less call
(e.g. getfillsettings()) is made, they will not be found by the linker (because seen as C++ calls, per the original header, thus mangled),
without any warnings at the compilation stage.

sample.cpp:
#include <grx20.h>
#include <libbcc.h>
#undef line // avoid macro interference
int main(void)
{
  line(1,2,3,4); // real function call now
  arc(1,2,3,4,5); // arc() has no macro defined, so real call here as well
  return 0;
}

gcc -Wall -o sample sample.cpp -lgrx20 -lgdi32
sample.o:sample.cpp:(.text+0x2e): undefined reference to `line(int, int, int, int)'
sample.o:sample.cpp:(.text+0x5a): undefined reference to `arc(int, int, int, int, int)'


*** libbcc.h.orig       2007-03-08 16:21:40.000000000 -0500
--- libbcc.h    2012-10-11 19:07:57.297854900 -0400
*************** void __gr_set_BGI_mode_whc(int *gd, int
*** 494,503 ****
  int  __gr_get_BGI_mode_pages(void);
  void __gr_set_BGI_mode_pages(int p);

- #ifdef __cplusplus
- }
- #endif
-
  /* ----------------------------------------------------------------- */
  /* ---           API functions with macro equivalents            --- */
  /* ---                      (for inlining)                       --- */
--- 494,499 ----
*************** int getactivepage(void);
*** 551,556 ****
--- 547,556 ----
  void setvisualpage(int p);
  int getvisualpage(void);

+ #ifdef __cplusplus
+ }
+ #endif
+
  /* ----------------------------------------------------------------- */
  #define restorecrtmode() __gr_restorecrtmode()
  #define getgraphmode() (__gr_INIT ? __gr_Mode : (__gr_Result=grNoInitGraph))

---
Cheers,
AL