mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
756 stars 138 forks source link

Avoid collisions when including .c files themselves #177

Closed xdevelnet closed 5 months ago

xdevelnet commented 2 years ago

Hello!

I attempted to use your project with the following scenario, which is described in README.md:

or alternatively add the sources md4c.[hc], md4c-html.[hc] and entity.[hc] into your code base

However, compiler yells about macro naming collisions:

md4c-html.c:67: warning: "ISDIGIT" redefined
   67 | #define ISDIGIT(ch)     ('0' <= (ch) && (ch) <= '9')
      | 
In file included:
md4c.c:314: note: this is the location of the previous definition
  314 | #define ISDIGIT(off)                    ISDIGIT_(CH(off))
      | 
In file included:
md4c-html.c:68: warning: "ISLOWER" redefined
   68 | #define ISLOWER(ch)     ('a' <= (ch) && (ch) <= 'z')
      | 
In file included:
md4c.c:312: note: this is the location of the previous definition
  312 | #define ISLOWER(off)                    ISLOWER_(CH(off))
      | 
In file included:
md4c-html.c:69: warning: "ISUPPER" redefined
   69 | #define ISUPPER(ch)     ('A' <= (ch) && (ch) <= 'Z')
      | 
In file included from:
md4c.c:311: note: this is the location of the previous definition
  311 | #define ISUPPER(off)                    ISUPPER_(CH(off))
      | 
In file included from:
md4c-html.c:70: warning: "ISALNUM" redefined
   70 | #define ISALNUM(ch)     (ISLOWER(ch) || ISUPPER(ch) || ISDIGIT(ch))
      | 
In file included from:
md4c.c:316: note: this is the location of the previous definition
  316 | #define ISALNUM(off)                    ISALNUM_(CH(off))
      | 

Also, macroses like ISLOWER are very commonly-used, so in order to easily include .c files directly into anyone's project, IMO it would be a great idea to add prefix to their names. I followed project naming rule (MD_ prefix) and did it on my own.

Regards, Xdevelnet

codecov[bot] commented 2 years ago

Codecov Report

Merging #177 (f81b3e8) into master (e9ff661) will not change coverage. The diff coverage is 98.46%.

@@           Coverage Diff           @@
##           master     #177   +/-   ##
=======================================
  Coverage   94.32%   94.32%           
=======================================
  Files           3        3           
  Lines        3100     3100           
=======================================
  Hits         2924     2924           
  Misses        176      176           
Impacted Files Coverage Δ
src/md4c.c 94.23% <98.44%> (ø)
src/md4c-html.c 95.20% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e9ff661...f81b3e8. Read the comment docs.