about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-01-29 12:23:24 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-01-29 12:41:20 -0800
commit7a13adb52c4964b91cf008c39f2e90ff5d9ec513 (patch)
tree5a92d9c7d18bee6928db9dffd6658083171acd68
parent24f0781d2bd96ac333337ccb2168fb26b601db7a (diff)
downloadteliva-7a13adb52c4964b91cf008c39f2e90ff5d9ec513.tar.gz
try to get by with one feature macro
I fucking hate feature macros. Egregious discharge of our
division-of-labor-obsessed society. People should be able to introduce
names. People should be able to give up names to lower levels of
abstraction when they encounter conflicts.

Feature macros seem to exist[1] to support more than two levels of
abstraction. You try to build, one of your libraries fails to build
because of a conflict between it and one level down. You don't want to
modify this library. Just fucking https://catern.com/change_code.html
already. But no, I have to litter my code with feature macros even
though I just want the abstraction the original library provides.

[1] https://man7.org/linux/man-pages/man7/feature_test_macros.7.html
    https://lwn.net/Articles/590381
-rw-r--r--src/Makefile2
-rw-r--r--src/kilo.c4
-rw-r--r--src/ldo.c1
-rw-r--r--src/teliva.c3
-rw-r--r--src/tlv.c2
5 files changed, 1 insertions, 11 deletions
diff --git a/src/Makefile b/src/Makefile
index 3d2a91e..c1334ad 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,7 +8,7 @@
 PLAT= none
 
 CC= gcc
-CFLAGS= -g -O2 -std=c99 -Wall -Wshadow $(MYCFLAGS)
+CFLAGS= -g -O2 -std=c99 -Wall -Wshadow $(MYCFLAGS) -D_DEFAULT_SOURCE
 AR= ar rc
 RANLIB= ranlib
 RM= rm -f
diff --git a/src/kilo.c b/src/kilo.c
index c7754e4..6dd293c 100644
--- a/src/kilo.c
+++ b/src/kilo.c
@@ -32,10 +32,6 @@
 
 #define KILO_VERSION "0.0.1"
 
-#ifdef __linux__
-#define _POSIX_C_SOURCE 200809L
-#endif
-
 #include <assert.h>
 #ifdef __NetBSD__
 #include <curses.h>
diff --git a/src/ldo.c b/src/ldo.c
index e1bf316..55ceae7 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -260,7 +260,6 @@ static StkId tryfuncTM (lua_State *L, StkId func) {
 /* based on getfuncname */
 extern Instruction symbexec (const Proto *pt, int lastpc, int reg);
 extern int luaL_newmetatable (lua_State *L, const char *tname);
-extern void endwin (void);
 void record_metadata_about_function_call (lua_State *L, CallInfo *ci) {
   if (!isLua(ci))
     return;
diff --git a/src/teliva.c b/src/teliva.c
index f3e6ceb..81997fc 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -172,7 +172,6 @@ void render_previous_error(void) {
   attroff(COLOR_PAIR(COLOR_PAIR_ERROR));
 }
 
-extern char* strdup(const char* s);
 int report_in_developer_mode(lua_State* L, int status) {
   if (status && !lua_isnil(L, -1)) {
     Previous_error = strdup(lua_tostring(L, -1));  /* memory leak */
@@ -749,8 +748,6 @@ void developer_mode(lua_State* L) {
   /* never returns */
 }
 
-extern int mkstemp(char* template);
-extern FILE* fdopen(int fd, const char* mode);
 void save_editor_state(int rowoff, int coloff, int cy, int cx) {
   if (strlen(Current_definition) == 0) return;
   char outfilename[] = "teliva_editor_state_XXXXXX";
diff --git a/src/tlv.c b/src/tlv.c
index 59f2e43..e9494af 100644
--- a/src/tlv.c
+++ b/src/tlv.c
@@ -128,8 +128,6 @@ void emit_multiline_string(FILE* out, const char* value) {
   }
 }
 
-extern int mkstemp(char *template);
-extern FILE *fdopen(int fd, const char *mode);
 void save_tlv(lua_State* L, char* filename) {
   lua_getglobal(L, "teliva_program");
   int history_array = lua_gettop(L);