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

json no longer compiles with TCC on OSX #23664

Closed
despiegk opened this issue Feb 7, 2025 · 4 comments
Closed

json no longer compiles with TCC on OSX #23664

despiegk opened this issue Feb 7, 2025 · 4 comments
Labels
Bug This tag is applied to issues which reports bugs. Build V build error on any OS/CPU architecture. Modules: JSON Bugs/feature requests, that are related to `json` and `x.json2` modules. OS: Mac Bugs/feature requests, that are specific to Mac OS.

Comments

@despiegk
Copy link
Contributor

despiegk commented Feb 7, 2025

Describe the bug

#!/usr/bin/env -S v -n -w -gc none  -cc tcc -d use_openssl -enable-globals run


import json

enum JobTitle {
    manager
    executive
    worker
}

struct Employee {
mut:
    name   string
    family string @[json: '-'] // this field will be skipped
    age    int
    salary f32
    title  JobTitle @[json: 'ETitle'] // the key for this field will be 'ETitle', not 'title'
    notes  string   @[omitempty]      // the JSON property is not created if the string is equal to '' (an empty string).
    // TODO: document @[raw]
}

x := Employee{'Peter', 'Begins', 28, 95000.5, .worker, ''}
println(x)
s := json.encode(x)
println('JSON encoding of employee x: ${s}')
assert s == '{"name":"Peter","age":28,"salary":95000.5,"ETitle":"worker"}'
mut y := json.decode(Employee, s)!
assert y != x
assert y.family == ''
y.family = 'Begins'
assert y == x
println(y)
ss := json.encode(y)
println('JSON encoding of employee y: ${ss}')
assert ss == s

Reproduction Steps

just do above

Expected Behavior

json works

Current Behavior

failed thirdparty object build cmd:
'/Users/despiegk/_code/v/thirdparty/tcc/tcc.exe' -std=c99 -D_DEFAULT_SOURCE -fwrapv -fPIC -I "/Users/despiegk/_code/v/thirdparty/cJSON" -o '/Users/despiegk/.vmodules/.cache/ad/ada83b1e9c1379329a100d8aeded1f07.module.json.o' -c '/Users/despiegk/_code/v/thirdparty/cJSON/cJSON.c'
builder error: In file included from /Users/despiegk/_code/v/thirdparty/cJSON/cJSON.c:59:
In file included from /Users/despiegk/_code/v/thirdparty/cJSON/cJSON.h:86:
thirdparty/tcc/lib/include/stddef.h:9: error: too many basic types

Possible Solution

?

Additional Information/Context

No response

V version

newest

Environment details (OS name and version, etc.)

osx
m.4

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.

@despiegk despiegk added the Bug This tag is applied to issues which reports bugs. label Feb 7, 2025
Copy link

Connected to Huly®: V_0.6-22085

@spytheman
Copy link
Member

On my m1, after adding -showcc too, and making the script executable:

Image

@spytheman
Copy link
Member

Can you please try: rm -rf thirdparty/tcc then gmake (to make sure that you have the latest tcc), and then try to run the same script ?

@felipensp felipensp added OS: Mac Bugs/feature requests, that are specific to Mac OS. Modules: JSON Bugs/feature requests, that are related to `json` and `x.json2` modules. Build V build error on any OS/CPU architecture. labels Feb 9, 2025
@despiegk
Copy link
Contributor Author

despiegk commented Feb 9, 2025

issue resolved, I used AI to find where conflict came from

// TODO: remove this patch, when tcc supports _Float16 natively.
//typedef float _Float16;

i still had this from before when there was other issue, now removed and it works as a charm (-:

@despiegk despiegk closed this as completed Feb 9, 2025
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. Build V build error on any OS/CPU architecture. Modules: JSON Bugs/feature requests, that are related to `json` and `x.json2` modules. OS: Mac Bugs/feature requests, that are specific to Mac OS.
Projects
None yet
Development

No branches or pull requests

3 participants