mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Updated cast code.
This commit is contained in:
committed by
Christoffer Lerno
parent
ca1885fe09
commit
37bb16cca1
@@ -161,10 +161,13 @@ macro void unsupported(String string = "Unsupported function invoked") @builtin
|
||||
**/
|
||||
macro bitcast(expr, $Type) @builtin
|
||||
{
|
||||
usz $size = $sizeof(expr);
|
||||
$Type x @noinit;
|
||||
mem::copy(&x, &expr, $size, $Type.alignof, $alignof(expr));
|
||||
return x;
|
||||
$if $Type.alignof <= $alignof(expr):
|
||||
return *($Type*)&expr;
|
||||
$else
|
||||
$Type x @noinit;
|
||||
$$memcpy(&x, &expr, $sizeof(expr), false, $Type.alignof, $alignof(expr));
|
||||
return x;
|
||||
$endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user