This folder contains example usage for both C and C++.
Because zvec uses macro generation to create type-safe containers, there is a one-time setup step to register your types.
-
Inside
include/either make your own registry header (likemy_vectors.hor something similar), or usezscanner.py. -
If you use the scanner, remember you can get it with:
git submodule update --init --recursiveThen just do:
python3 ../z-core/zscanner.py c/ include/z_registry.hNote: If you are compiling the C++ examples change
c/tocpp/
Expect an output like this:
Scanning c/...
Generating include/z_registry.h...
Done.z_registry.h should look similar to this:
/* AUTO-GENERATED BY Z-SCANNER - DO NOT EDIT */
#ifndef Z_REGISTRY_H
#define Z_REGISTRY_H
/* Vectors */
#define Z_AUTOGEN_VECS(X) \
X(int, Int) \
X(Point, Point) \
/* Lists */
#define Z_AUTOGEN_LISTS(X) \
/* Maps */
#define Z_AUTOGEN_MAPS(X) \
#endif // Z_REGISTRY_H
- To compile then you can simply do:
For C:
gcc c/example_0.c -I.. -Iinclude -o example_c
./example_cFor C++:
g++ cpp/example_0.cpp -I.. -Iinclude -o example_cpp
./example_cpp-I.. is needed to include zvec.h. You can simply just move it, but this way we keep the current structure. -Iinclude includes the registry header.