Vezel.Zig.Sdk

본문 바로가기
사이트 내 전체검색

로그인
회원가입
IT Note

Vezel.Zig.Sdk
3

View 33  | 작성일2025.07.31 15:49

첨부파일

본문

https://docs.vezel.dev/zig-sdk/usage


- MyZig.zigproj

<Project Sdk="Vezel.Zig.Sdk">
<PropertyGroup>
<TargetFramework>net9.0TargetFramework>
<OutputType>LibraryOutputType>
<CompilerMode>zigCompilerMode>
PropertyGroup>
Project>


- MyZig.zig

export fn add(a: i32, b: i32) i32 {
return a + b;
}
 


- MyCs.csproj

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>ExeOutputType>
<TargetFramework>net9.0TargetFramework>
<ImplicitUsings>enableImplicitUsings>
<Nullable>enableNullable>
PropertyGroup>

<ItemGroup>
<ProjectReference Include="../MyZig/MyZig.zigproj" />
ItemGroup>

<PropertyGroup>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(MSBuildRuntimeIdentifier)RuntimeIdentifier>
PropertyGroup>

<Target Name="CopyZigLib" AfterTargets="Build">
<Copy SourceFiles="..\MyZig\bin\Debug\$(RuntimeIdentifier)\libMyZig.so"
DestinationFolder="$(OutputPath)"
Condition="Exists('..\MyZig\bin\Debug\$(RuntimeIdentifier)\libMyZig.so')" />
Target>
Project>


- Program.cs

using System;
using System.Runtime.InteropServices;

class Program
{
[DllImport("MyZig", CallingConvention = CallingConvention.Cdecl)]
public static extern int add(int a, int b);

static void Main()
{
Console.WriteLine($"3 + 5 = {add(3, 5)}");
}
}




5733700829226505088ca2ca933c0da4_1753944624_1745.png
5733700829226505088ca2ca933c0da4_1753944626_644.png
 



댓글목록

zig 언어 (c++ 대안 언어 중 하나) 를.. 닷넷 프로젝트랑 쓰게 해주는 거라더라고요.
실제 쓸일은 없을 거 같아요..;

IT Tip&Tech 목록

게시물 검색

접속자집계

오늘
559
어제
1,239
최대
6,399
전체
1,375,896
Copyright © LittleCandle All rights reserved.
문의메일 : littlecandle99@gmail.com
모바일 버전으로 보기