krakjoe / cmark

CommonMark for PHP
Other
46 stars 7 forks source link

cmark 1.2.0 doesn't compile with Visual Studio #20

Open cmb69 opened 4 years ago

cmb69 commented 4 years ago

Syntax like https://github.com/krakjoe/cmark/blob/c71ebe2e388239c9cc0fb95d06330fc10535d125/src/block.c#L89-L95 isn't supported by Visual Studio compilers (and maybe others as well). The problem is that the php_cmark_assert_type macro gets resolved before the conditional compilation, and is expanded on a single line, yielding invalid syntax.

Maybe it's best to rewrite this as:

 #if PHP_VERSION_ID >= 70400 
            php_cmark_assert_type(value, IS_STRING, 0, return &EG(uninitialized_zval), "fence expected to be string"); 
 #else 
            php_cmark_assert_type(value, IS_STRING, 0, return, "fence expected to be string"); 
 #endif 
cmb69 commented 1 month ago

Since I've just stumbled upon this issue again, I've tried with the new VS preprocessor, and got C5101:

use of preprocessor directive in function-like macro argument list is undefined behavior

Note that makes it impossible to build this extension with VS (and maybe other compiler tool chains) as of PHP 7.4.0 cmark 1.2.0.

macintoshplus commented 3 weeks ago

I can buil for PHP 8 and VS16 with a patch from #24 and some other change to fix the build. But some change break the build for PHP 7.4.

The DLL: https://phpext.phptools.online/extension/text/cmark-360