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

add command for generate c project #19972

Open
2 tasks
Jimmy2099 opened this issue Nov 23, 2023 · 0 comments
Open
2 tasks

add command for generate c project #19972

Jimmy2099 opened this issue Nov 23, 2023 · 0 comments
Labels
Feature Request This issue is made to request a feature.

Comments

@Jimmy2099
Copy link

Jimmy2099 commented Nov 23, 2023

Describe the feature

C:\v\examples>v run json.v
Frodo: 25
Bobby: 10

0) Frodo
Frodo is registered
1) Bobby
Cannot register Bobby, they are too young

[{"name":"Frodo","age":25,"is_registered":true},{"name":"Bobby","age":10,"is_registered":false}]

C:\v\examples>v -o main.c json.v

C:\v\examples>v run js_dom_cube

C:\v\examples>gcc main.c

      |                                        json__encode_Array_main__User
main.c:13229:40: error: invalid initializer
main.c:13230:9: warning: implicit declaration of function 'cJSON_Delete' [-Wimplicit-function-declaration]
13230 |         cJSON_Delete(_t2); // del
      |         ^~~~~~~~~~~~
main.c:13256:9: error: unknown type name 'cJSON'; use 'struct' keyword to refer to the type
13256 |         cJSON* _t5 = json__encode_Array_main__User(users);
      |         ^~~~~
      |         struct
main.c:13257:39: warning: passing argument 1 of 'json__json_print' from incompatible pointer type [-Wincompatible-pointer-types]
13257 |         string _t6 = json__json_print(_t5);
      |                                       ^~~

and then get some error , because miss some library, and the correct command to build exe is
C:\v\examples>v -showcc -o main.exe json.v

C compiler cmd: gcc "@C:\Users\Administrator\AppData\Local\Temp\1\v_0\main.exe.7518637108978682928.tmp.c.rsp"
C compiler response file "C:\Users\Administrator\AppData\Local\Temp\1\v_0\main.exe.7518637108978682928.tmp.c.rsp":
-fwrapv "C:\Users\Administrator\.vmodules\cache\6a\6a1503cbfeea6dfb273b4562f3ab7513.module.builtin.o" "C:\Users\Administrator\.vmodules\cache\de\decdad51df91454f3c9a70d95f03b93c.module.json.o" -o "C:\v\examples\main.exe" -Wl,-stack=16777216 -Werror=implicit-function-declaration -D GC_NOT_DLL=1 -D GC_WIN32_THREADS=1 -D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "C:\v\thirdparty\libgc\include" -I "C:\v\thirdparty\cJSON" "C:\Users\Administrator\AppData\Local\Temp\1\v_0\main.exe.7518637108978682928.tmp.c" -std=c99 -D_DEFAULT_SOURCE -municode -ldbghelp

so, it is possible to add a command like this

v -generate-c-project main .

to generate the correct makefile or cmakefile withc c code and without .o file with all the library source which this project depend on

because when I checked the command showcc generate it includes ".o" file in temp dir
"C:\Users\Administrator\.vmodules\cache\6a\6a1503cbfeea6dfb273b4562f3ab7513.module.builtin.o"
or could it possible just write the command down into the text file the can build and run manually,like this

gcc main.c -fwrapv "C:\\Users\\Administrator\\.vmodules\\cache\\6a\\6a1503cbfeea6dfb273b4562f3ab7513.module.builtin.o" -I "C:\\v\\thirdparty\\libgc\\include" ... -std=c99 -D_DEFAULT_SOURCE -municode -ldbghelp ...

Use Case

generate the correct c or cpp project and know how to work with existing c and cpp project

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.3 cd337e2

Environment details (OS name and version, etc.)

Windows 10

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.

@Jimmy2099 Jimmy2099 added the Feature Request This issue is made to request a feature. label Nov 23, 2023
@felipensp felipensp changed the title add commond for generate c project add command for generate c project Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

1 participant