Open kassane opened 1 year ago
The types of atomic sorting need to be completely revised. I was only able to test the string.
By the way, during the tests I saw (std.debug.print
) that in the for-loop of the cpp_vector test, empty values with zero elements are compared.
I don't think the String impl is right, did it pass the tests ?!?! If you look at how cpp.Vector
you see that C++ stores 3 pointers one for the start other for the end of the used data and other pointing to the end of the memory slice;
Try to remove the implementations of SampleObject
from the header file, so the transpiled code acctually calls c++ compiled code, the transpiler it's far from been able to handle all c++ semantics, specially when dealing with std containers.
I don't think the String impl is right, did it pass the tests ?!?!
Yeah!
However, as I mentioned, the update would be from Zig to Zig. I can't receive C++ strings just like cpp_vector doesn't receive values.
As for smart pointers, I'll need to do implementation tests. Although it compiles without error.
the transpiler it's far from been able to handle all c++ semantics, specially when dealing with std containers.
I agree! I'll try use the .c_str()
in std::string
and .data()
in std::vector
and std::array
when carrying out tests on the containers.
I did some work implement std::string
, it's working but only for gnu abi, is in the newest branch.
I did some work implement
std::string
, it's working but only for gnu abi, is in the newest branch.
I've seen and tested it and also it's not available for msvc yet.
A question: Did you try viewing std::string
from llvm-libcxx
?
llvm-libcxx
? why the particular interest on msvc? is there any lib or project that requires it?
llvm-libcxx
? why the particular interest on msvc? is there any lib or project that requires it?
Two aspects here.
First, we already know that msvc is microsoft's standard abi. To date zig toolchain (clang-cl
) does not support libc++
in msvc target, making nostdlib++
.
Second, about libc++
and libstdc++
know that they are not that compatible as expected. Having zig toolchain
as primary objective it's usual to think llvm-libcxx
only except you want to host-build (killing cross-compilation).
https://github.com/ziglang/zig/blob/master/lib/libcxx/src/string.cpp
e.g. (zig c++ w/ libstdc++
): https://gist.github.com/kassane/7e9a2da137e13eb6e1dbab726693bdb7?permalink_comment_id=4475986#gistcomment-4475986
Reference: https://github.com/ziglang/zig/wiki/Troubleshooting-Build-Issues#dual-abi-linking
Most game devlopers look for msvc compatibility, being the case of the zig-gamedev project and unreal (TODO: testing...)!
I don't understand what you mean with the first part
I don't understand what you mean with the first part
What exactly?
MSVC target doesn't use zig libcxx
and requires linking windows crt and sdk libraries directly.
--- edit
Missing Second,
- About libc++ and libstdc++ know
+ Second, about libc++ and libstdc++ know
MSVC string works completly different from the clang implementation :( it requires a second implementation
For some reasong I can't build with:
zig build test -Doptimize=ReleaseFast -freference-trace -Dtarget=native-windows-msvc
For some reasong I can't build with:
zig build test -Doptimize=ReleaseFast -freference-trace -Dtarget=native-windows-msvc
Could you show the error that occurred in the msvc build?
My case (Linux user), I use xwin to download libraries + includes sdk and crt (VS 2019/ 16 version). https://github.com/kassane/c2z/blob/msvc/build.zig#L100
The last CI commit returns the @compileError
to msvc.
Ok I manage to build, but the tests exit with error code 5, have no clue how to fix it.
I finnaly figure out, it was a small mistake on my end, I had to make MSVC work in debug builds and it does sort of does ...
By the way xWin isn't needed at all
I finnaly figure out, it was a small mistake on my end, I had to make MSVC work in debug builds and it does sort of does
Great!
By the way xWin isn't needed at all
Yes! needed for non-windows or another arch-msvc only. Because zig toolchain statically configures msvc target (it does not switch to x86 or aarch64).
@lassade, have you tested astd::vector<std::vector<T>>
?
no, but theres no reason why it can't work
no, but theres no reason why it can't work
Transpiling test
- bool enumerate(std::vector<uint8_t>& out_buf, size_t count);
+ bool enumerate(std::vector<std::vector<uint8_t>>& out_buf, size_t count);
info: using host `x86_64-linux-gnu` as target
info: zig cc -x c++ -lc++ -Xclang -ast-dump=json -fsyntax-only -target x86_64-linux-gnu
info: binding `test_cases/include/c013_cpp_vector.h`
thread 51809 panic: integer overflow
/home/kassane/Documentos/c2z/src/Transpiler.zig:2436:34: 0x2845be in transpileType (c2z)
const ch = ttname[ttname.len - 1];
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:2553:48: 0x287a4a in transpileArgs (c2z)
const name = try self.transpileType(arg);
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:2548:35: 0x2878d4 in transpileArgs (c2z)
try self.transpileArgs(args, buffer, index);
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:2501:31: 0x285cee in transpileType (c2z)
try self.transpileArgs(ttname[less_than..], &args, &index);
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:2464:43: 0x284d78 in transpileType (c2z)
var inner = try self.transpileType(raw_name);
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:1060:52: 0x29252a in visitCXXMethodDecl (c2z)
var z_type = try self.transpileType(c_type);
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:1548:35: 0x259a9a in visit (c2z)
return self.visitCXXMethodDecl(value, null);
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:425:27: 0x282158 in visitTranslationUnitDecl (c2z)
try self.visit(item);
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:312:42: 0x259773 in visit (c2z)
try self.visitTranslationUnitDecl(value);
^
/home/kassane/Documentos/c2z/src/Transpiler.zig:191:19: 0x24816c in run (c2z)
try self.visit(value);
^
/home/kassane/Documentos/c2z/src/main.zig:130:27: 0x244d84 in main (c2z)
try transpiler.run(&tree.value);
^
/home/kassane/zig/0.11.0-dev.3937+78eb3c561/files/lib/std/start.zig:608:37: 0x23eea4 in posixCallMainAndExit (c2z)
const result = root.main() catch |err| {
^
/home/kassane/zig/0.11.0-dev.3937+78eb3c561/files/lib/std/start.zig:367:5: 0x23e991 in _start (c2z)
@call(.never_inline, posixCallMainAndExit, .{});
^
[1] 51809 IOT instruction (core dumped) ./zig-out/bin/c2z -no-glue test_cases/include/c013_cpp_vector.h
``
zig version:
0.11.0-dev.3905+309aacfc8
std::string
Test
Update: Wrong!! No C++ receiver in
DoSomething()
.source:
Impl - WiP