Skip to content

Instantly share code, notes, and snippets.

@androm3da
Created August 26, 2016 14:03
Show Gist options
  • Save androm3da/9126ff51b5b47f69b99b1e3db845d85b to your computer and use it in GitHub Desktop.
Save androm3da/9126ff51b5b47f69b99b1e3db845d85b to your computer and use it in GitHub Desktop.
#include <iostream>
#include <uuid/uuid.h>
extern "C" int foo(int x);
int main(int argc, char *argv[])
{
auto total = foo(argc) + foo(argc);
uuid_t u;
uuid_generate(u);
char uuid_text[37];
uuid_unparse(u, uuid_text);
std::cout << "UUID: " << uuid_text << "\n";
return total;
}
int foo(int x)
{
return x+x;
}
all: foo
CXXFLAGS+= -std=c++11 -Wall
LDLIBS+=-lstdc++ $(shell pkg-config --libs uuid)
foo: foo.o bar.o
.PHONY: clean all
clean:
$(RM) foo foo.o bar.o
$ make clean
rm -f foo foo.o bar.o
$ make CXX=clang++ && ./foo ; echo $?
cc -c -o foo.o foo.c
clang++ -std=c++11 -Wall -c -o bar.o bar.cpp
cc foo.o bar.o -lstdc++ -luuid -o foo
UUID: e55e3138-5634-4852-87fd-ab993d2a95d1
4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment