Skip to content

Commit

Permalink
Include c header
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ortmann committed Feb 12, 2024
1 parent 803b482 commit 4d7a884
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
7 changes: 0 additions & 7 deletions src/eggdrop.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@
#define PASSWORDMAX 30 /* highest value compatible to older eggdrop */
#define PASSWORDLEN PASSWORDMAX + 1


/* We have to generate compiler errors in a weird way since not all compilers
* support the #error preprocessor directive. */
#ifndef STDC_HEADERS
# include "Error: Your system must have standard ANSI C headers."
#endif

#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
Expand Down
7 changes: 1 addition & 6 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@
# define TCL_CONST86
#endif

#ifdef HAVE_STDARG_H
# include <stdarg.h>
#else
# error "Must have stdarg.h"
#endif

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion src/mod/zig.mod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static: ../zig.o
modules: ../../../zig.$(MOD_EXT)

../zig.o:
zig build-lib -fPIC zig.zig
zig build-lib -fPIC -lc -isystem ../../.. zig.zig
mv libzig.a.o ../zig.o

../../../zig.$(MOD_EXT): ../zig.o
Expand Down
17 changes: 13 additions & 4 deletions src/mod/zig.mod/zig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@
//
// Copyright (c) 2024 Michael Ortmann

const MODULE_NAME: []u8 = "zig";

const c = @cImport({
// See https://github.com/ziglang/zig/issues/515
@cDefine("_NO_CRT_STDIO_INLINE", "1");
@cInclude("src/mod/module.h");
});

const std = @import("std");

export fn zig_start() ?[*]const u8 {
const stdout = std.io.getStdOut().writer();
stdout.print("Hello, {s}!\n", .{"world"}) catch return null;
return "WIP".ptr;
export fn zig_start(global_funcs: c.global) ?[*]const u8 {
_ = global_funcs;

std.io.getStdOut().writer().print("hello from zig.mod zig_start()\n", .{}) catch return null;
return "WIP".ptr;
}

0 comments on commit 4d7a884

Please sign in to comment.