C

C is the ancestor of C++ and remains the lingua franca of low-level systems: operating system kernels, device drivers, sensor firmware, and many embedded runtimes are written in C. You will rarely write a full SLAM system in C, but you will constantly read and interface with C code.

What to learn

#include <stdlib.h>

typedef struct { float x, y, z; } Point3;

Point3* cloud_alloc(size_t n) {
    return (Point3*)malloc(n * sizeof(Point3));  /* must free() later */
}

/* Callback registration, the universal sensor-SDK pattern */
typedef void (*frame_cb)(const unsigned char* data, int w, int h, void* user);
void sensor_set_callback(frame_cb cb, void* user_data);

Bridging C and C++

C++ compilers mangle function names to encode types; C does not. extern "C" tells the C++ compiler to use C linkage so the two worlds can call each other:

extern "C" {
#include "vendor_camera_sdk.h"   // C header from the sensor vendor
}

// C++ wrapper: RAII around the C API's open/close pair
class Camera {
public:
    Camera()  { handle_ = vendor_cam_open(); }
    ~Camera() { vendor_cam_close(handle_); }
private:
    vendor_cam_handle* handle_;
};

This wrapper pattern — C API inside, RAII outside — is how well-engineered SLAM codebases contain the unsafety of C interfaces.

Where C shows up in SLAM work

Common pitfalls

Why it matters for SLAM

Real-time SLAM lives close to the hardware, and the boundary between your algorithm and the sensors, OS, and accelerators is almost always a C interface. Reading C fluently — and understanding manual memory management — makes you a better C++ programmer and lets you debug the full stack, from driver callback to bundle adjustment. Most learners can treat C as a companion to C++ study rather than a separate deep dive.