Skip to content

Commit

Permalink
Merge pull request #184 from Icantjuddle/add_cpp_extern
Browse files Browse the repository at this point in the history
Add extern "C" to headers when being compiled in c++.
  • Loading branch information
jhawthorn authored Dec 7, 2024
2 parents b2389a6 + 3a18370 commit 19db853
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/bonus.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "../config.h"

#ifdef __cplusplus
extern "C" {
#endif

#define ASSIGN_LOWER(v) \
['a'] = (v), \
['b'] = (v), \
Expand Down Expand Up @@ -105,4 +109,8 @@ const size_t bonus_index[256] = {

#define COMPUTE_BONUS(last_ch, ch) (bonus_states[bonus_index[(unsigned char)(ch)]][(unsigned char)(last_ch)])

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions src/choices.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "match.h"
#include "options.h"

#ifdef __cplusplus
extern "C" {
#endif

struct scored_result {
score_t score;
const char *str;
Expand Down Expand Up @@ -38,4 +42,8 @@ score_t choices_getscore(choices_t *c, size_t n);
void choices_prev(choices_t *c);
void choices_next(choices_t *c);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions src/config.def.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifdef __cplusplus
extern "C" {
#endif

#define TTY_COLOR_HIGHLIGHT TTY_COLOR_YELLOW

#define SCORE_GAP_LEADING -0.005
Expand All @@ -17,3 +21,7 @@
#define DEFAULT_NUM_LINES 10
#define DEFAULT_WORKERS 0
#define DEFAULT_SHOW_INFO 0

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/match.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include <math.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef double score_t;
#define SCORE_MAX INFINITY
#define SCORE_MIN -INFINITY
Expand All @@ -13,4 +17,8 @@ int has_match(const char *needle, const char *haystack);
score_t match_positions(const char *needle, const char *haystack, size_t *positions);
score_t match(const char *needle, const char *haystack);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef OPTIONS_H
#define OPTIONS_H OPTIONS_H

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
int benchmark;
const char *filter;
Expand All @@ -18,4 +22,8 @@ typedef struct {
void options_init(options_t *options);
void options_parse(options_t *options, int argc, char *argv[]);

#ifdef __cplusplus
}
#endif

#endif
1 change: 0 additions & 1 deletion src/tty.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
Expand Down
10 changes: 10 additions & 0 deletions src/tty.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#ifndef TTY_H
#define TTY_H TTY_H

#include <stddef.h>
#include <stdio.h>
#include <termios.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
int fdin;
FILE *fout;
Expand Down Expand Up @@ -57,4 +63,8 @@ void tty_flush(tty_t *tty);
size_t tty_getwidth(tty_t *tty);
size_t tty_getheight(tty_t *tty);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions src/tty_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "options.h"
#include "tty.h"

#ifdef __cplusplus
extern "C" {
#endif

#define SEARCH_SIZE_MAX 4096

typedef struct {
Expand All @@ -25,4 +29,8 @@ typedef struct {
void tty_interface_init(tty_interface_t *state, tty_t *tty, choices_t *choices, options_t *options);
int tty_interface_run(tty_interface_t *state);

#ifdef __cplusplus
}
#endif

#endif

0 comments on commit 19db853

Please sign in to comment.