Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

inline function in c example

// file test.h
#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED
inline int sum (int a, int b)
{
    return a+b;
}
#endif
 
// file sum.c
#include "test.h"
extern inline int sum (int a, int b); // provides external definition
 
// file test1.c
#include <stdio.h>
#include "test.h"
extern int f(void);
 
int main(void)
{
    printf("%d
", sum(1, 2) + f());
}
 
// file test2.c
#include "test.h"
 
int f(void)
{
    return sum(2, 3);
}
Source by en.cppreference.com #
 
PREVIOUS NEXT
Tagged: #inline #function
ADD COMMENT
Topic
Name
9+4 =