Skip to content

Data Types

Derek Snider edited this page May 19, 2026 · 1 revision

Data Types

madc supports C integer types, floating point, strings, and typed containers.

Numeric Types

Type Size Description
int / int64_t 8 bytes 64-bit signed integer (default integer type)
int8_t 1 byte Signed byte
int16_t 2 bytes Signed 16-bit
int32_t 4 bytes Signed 32-bit
uint8_t 1 byte Unsigned byte
uint16_t 2 bytes Unsigned 16-bit
uint32_t 4 bytes Unsigned 32-bit
uint64_t 8 bytes Unsigned 64-bit
char 1 byte 8-bit character
float 4 bytes Single-precision floating point
double 8 bytes Double-precision floating point

String

string s = "hello world";
cout << s << endl;

string is backed by C++ std::string. Strings are mutable, grow automatically, and support cout << output. Many namespace functions operate on strings.

Array

array names;
php::array_push(names, "Alice");
php::array_push(names, "Bob");
php::array_push_int(names, 42);

array is a mixed-type container (MadValue-based). Elements can be strings or integers. Manipulated via php:: array functions and iterable with range-based for.

Typed Containers (STL)

vector<int> nums;
nums.push_back(10);
nums.push_back(20);

map<string, int> ages;
ages["Alice"] = 30;

set<string> unique;
unique.insert("hello");

Also accessible as std::vector<int>, std::map<string, int>, etc.

Streams

Type Description
cout / cerr Standard output / error (also std::cout, std::cerr)
cin Standard input (see Strings & I/O)
stringstream In-memory string stream
ifstream File input stream
ofstream File output stream
fstream File input/output stream

User-Defined Types

struct Point {
    int x;
    int y;
};

class Person {
    string name;
    int age;
};

Point p;        // no 'struct' prefix needed
Person bob;

See Structs & Classes for more.

Type Inference

x := 42;              // x is int
name := "hello";      // name is string
auto fn = my_func;    // fn is a function pointer

:= infers the type from the right-hand side. auto infers from function pointer or lambda assignments.

Pointers

int x = 42;
int *p = &x;
cout << *p << endl;   // 42

char *s = "hello";
puts(s);

C-style pointers work as expected. See Pointers & Arrays.

What's next?

Clone this wiki locally