infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
Ch02_ArrayDecay.c File Reference

Cookbook Chapter 2: Working with Fixed-Size Arrays. More...

#include <infix/infix.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
Include dependency graph for Ch02_ArrayDecay.c:

Functions

static int64_t sum_array_elements (const int64_t *arr, size_t count)
 
int main ()
 

Detailed Description

Cookbook Chapter 2: Working with Fixed-Size Arrays.

This example clarifies a common point of confusion when working with arrays in C. When an array is passed as a function argument, it "decays" into a pointer to its first element. Therefore, the infix signature must describe it as a pointer, not an array type.

The [N:type] array syntax is only used to describe an array when it is a member of a struct or a return type (a rare case).

Function Documentation

◆ main()

int main ( void  )

◆ sum_array_elements()

static int64_t sum_array_elements ( const int64_t *  arr,
size_t  count 
)
static