Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: conflicting types for 'gc_enable' #24095

Open
guweigang opened this issue Mar 31, 2025 · 3 comments
Open

error: conflicting types for 'gc_enable' #24095

guweigang opened this issue Mar 31, 2025 · 3 comments
Labels
Bug This tag is applied to issues which reports bugs. Modules: builtin Bugs and problems, concerning the builtin types in V - array, maps, strings, runes. Reimplement Feature This issue is related to significant changes of existing feature.

Comments

@guweigang
Copy link

guweigang commented Mar 31, 2025

Describe the bug

Recently, I used Vlang to write an extension for php which depends on php development codebase. When I build shared library using this command v -enable-globals -shared -cg -o test.so ., errors just occured like below:

/tmp/v_501/test.so.01JQMZQZVRYJFNVV3YDW1Q5284.tmp.so.c:2135:6: error: conflicting types for 'gc_enable'
 2135 | void gc_enable(void);
      |      ^
/opt/homebrew/Cellar/php/8.4.5/include/php/Zend/zend_gc.h:52:15: note: previous declaration is here
   52 | ZEND_API bool gc_enable(bool enable);
      |               ^
/tmp/v_501/test.so.01JQMZQZVRYJFNVV3YDW1Q5284.tmp.so.c:7904:20: warning: ordered comparison between pointer and integer ('usize' (aka 'unsigned long') and 'voidptr' (aka 'void *'))
 7904 |                         if (nextp->head < old_end) {
      |                             ~~~~~~~~~~~ ^ ~~~~~~~
/tmp/v_501/test.so.01JQMZQZVRYJFNVV3YDW1Q5284.tmp.so.c:9872:6: error: conflicting types for 'gc_enable'
 9872 | void gc_enable(void) {
      |      ^
/opt/homebrew/Cellar/php/8.4.5/include/php/Zend/zend_gc.h:52:15: note: previous declaration is here
   52 | ZEND_API bool gc_enable(bool enable);

What should I do to avoid this?

Reproduction Steps

none

Expected Behavior

Maybe Vlang should add prefix for exporting function, like vweb, here maybe v_gc_enable ?

Current Behavior

conflicting types for 'gc_enable'

Possible Solution

No response

Additional Information/Context

No response

V version

0.4.10

Environment details (OS name and version, etc.)

macOS 15.3.2

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@guweigang guweigang added the Bug This tag is applied to issues which reports bugs. label Mar 31, 2025
Copy link

Connected to Huly®: V_0.6-22486

@spytheman
Copy link
Member

You will have to edit either the generated .c or .h file, and delete one of the conflicting declarations, because unfortunately in C libraries, function symbols are globally scoped, and thus there can be name collisions.

@spytheman spytheman reopened this Mar 31, 2025
@spytheman spytheman added Modules: builtin Bugs and problems, concerning the builtin types in V - array, maps, strings, runes. Reimplement Feature This issue is related to significant changes of existing feature. labels Mar 31, 2025
@guweigang
Copy link
Author

You will have to edit either the generated .c or .h file, and delete one of the conflicting declarations, because unfortunately in C libraries, function symbols are globally scoped, and thus there can be name collisions.

Editing either the generated .c or .h file every time would not be a solution. Maybe the problem was caused by this pull #21002

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Modules: builtin Bugs and problems, concerning the builtin types in V - array, maps, strings, runes. Reimplement Feature This issue is related to significant changes of existing feature.
Projects
None yet
Development

No branches or pull requests

2 participants