mity / md4c

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

Redefinition of macroses while including .c into project #194

Closed xdevelnet closed 5 months ago

xdevelnet commented 1 year ago

Hi! I'm trying to use this project just as described in statements below (from README.md):

Converting to HTML

If you need to convert Markdown to HTML, include md4c-html.h and link against MD4C-HTML library (-lmd4c-html); or alternatively add the sources md4c.[hc], md4c-html.[hc] and entity.[hc] into your code base.

So, here i am, including all .c files in order to do the job:

#include "../md4c/src/entity.c"
#include "../md4c/src/md4c.c"
#include "../md4c/src/md4c-html.c"

But it seems like the project is not suitable for such use, because there is multiple definitions with common names inside these .c files which not only could make collisions with user's project, but it actually is collision with itself:

../md4c/src/md4c-html.c:67: warning: "ISDIGIT" redefined
   67 | #define ISDIGIT(ch)     ('0' <= (ch) && (ch) <= '9')
      | 
In file included from ...,
                 ../md4c/src/md4c.c:314: note: this is the location of the previous definition
  314 | #define ISDIGIT(off)                    ISDIGIT_(CH(off))
      | 

So, my question is:

  1. I am doing something wrong?
  2. Maybe these macroses should be renamed somehow in order to avoid collisions with project and between these two files: md4c.c, md4c-html.c.

List of collisioned macroses between md4c.c and md4c-html.c:

  1. ISDIGIT
  2. ISLOWER
  3. ISUPPER
  4. ISALNUM

Regards,

mity commented 5 months ago

Sorry, the word "include" here means: "Add those files" into your project, so that they are compiled as any other .c file, not in the sense of C preprocessor directive #include.