#include <stdio.h>
#include <stdarg.h>
int hello[100];
int world[100];
int* __attribute__((__weak__, __visibility__("hidden"))) getHello() {
return hello;
}
int* __attribute__((__weak__, __visibility__("hidden"))) getWorld() {
return world;
}
long long __attribute__((__weak__, __visibility__("hidden"))) add64(long long a, long long b) {
return a + b;
}
int __attribute__((__weak__, __visibility__("hidden"))) vararg(int n, ...) {
int res = 0;
va_list vl;
va_start(vl, n);
for (int i = 0; i < n; i++)
res += va_arg(vl, int);
va_end(vl);
return res;
}
char s[5];
int main() {
int a = vararg(5, 1, 2, 3, 4, 5);
s[0] = a/10+'0';
s[1] = a%10+'0';
s[2] = '\0';
puts(s);
return 0;
}Clang is a drop-in replacement for GCC, so whatever explained in that page for symbol visibility is applicable for Clang as well.
You didn't say exactly what didn't work for you.
.hidden foo
.globl foo
.type foo,@function .hidden foo
.weak foo
.type foo,@function (export "getHello" (func $0))
(export "getWorld" (func $1))
(export "add64" (func $2))
(export "vararg" (func $3))
(export "main" (func $4))--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.