-
Notifications
You must be signed in to change notification settings - Fork 833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler warnings #58
Comments
that is a warning, it still compiles. |
> make
> cc -o kilo kilo.c -Wall -W -pedantic -std=c99
> In file included from /usr/include/termios.h:25,
> from kilo.c:40:
> /usr/include/features.h:184:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
> # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
> ^~~~~~~
> kilo.c: In function ‘editorRefreshScreen’:
> kilo.c:953:19: warning: implicit declaration of function ‘time’; did you mean ‘tee’? [-Wimplicit-function-declaration]
> if (msglen && time(NULL)-E.statusmsg_time < 5)
> |
with linux.gcc 9.2.1: it's very easy to avoid the warnings. I just paste the corrected code: /* Kilo -- A very simple editor in less than 1-kilo lines of code (as counted
#define KILO_VERSION "0.0.1" /* #define _BSD_SOURCE -dod / #include <termios.h> /* Syntax highlight types / #define HL_HIGHLIGHT_STRINGS (1<<0) struct editorSyntax { /* This structure represents a single line of the file we are editing. / typedef struct hlcolor { struct editorConfig { static struct editorConfig E; enum KEY_ACTION{ void editorSetStatusMessage(const char *fmt, ...); /* =========================== Syntax highlights DB =========================
/* C / C++ */ /* Here we define an array of syntax highlights by extensions, keywords,
#define HLDB_ENTRIES (sizeof(HLDB)/sizeof(HLDB[0])) /* ======================= Low level terminal handling ====================== */ static struct termios orig_termios; /* In order to restore at exit.*/ void disableRawMode(int fd) { /* Called at exit to avoid remaining in raw mode. */ /* Raw mode: 1960 magic shit. */
fatal: /* Read a key from the terminal put in raw mode, trying to handle
/* Use the ESC [6n escape sequence to query the horizontal cursor position
/* Try to get the number of columns in the current terminal. If the ioctl()
failed: /* ====================== Syntax highlight color scheme ==================== */ int is_separator(int c) { /* Return true if the specified row last char is part of a multi line comment
/* Set every byte of row->hl (that corresponds to every character in the line)
/* Maps syntax highlight token types to terminal colors. / /* Select the syntax highlight scheme depending on the filename,
/* ======================= Editor rows implementation ======================= */ /* Update the rendered version and the syntax highlight of a row. */ /* Create a version of the row we can directly print on the screen,
} /* Insert a row at the specified position, shifting the other rows on the bottom
/* Free row's heap allocated stuff. */ /* Remove the row at the specified position, shifting the remainign on the
/* Turn the editor rows into a single heap-allocated string.
/* Insert a character at the specified position in a row, moving the remaining
/* Append the string 's' at the end of a row */ /* Delete the character at offset 'at' from the specified row. */ /* Insert the specified char at the current prompt position. */
} /* Inserting a newline is slightly complex as we have to handle inserting a
/* Delete the char at the current prompt position. */
} /* Load the specified program in the editor memory and returns 0 on success
/* Save the current file on disk. Return 0 on success, 1 on error. */
writeerr: /* ============================= Terminal update ============================ */ /* We define a very simple "append buffer" structure, that is an heap
#define ABUF_INIT {NULL,0} void abAppend(struct abuf *ab, const char *s, int len) {
} void abFree(struct abuf *ab) { /* This function writes the whole screen using VT100 escape characters
/* Set an editor status message for the second line of the status, at the
/* =============================== Find mode ================================ */ #define KILO_QUERY_LEN 256 void editorFind(int fd) { #define FIND_RESTORE_HL do {
} /* ========================= Editor events handling ======================== */ /* Handle cursor position change because arrow keys were pressed. */
} /* Process events arriving from the standard input, which is, the user
int editorFileWasModified(void) { void initEditor(void) { int main(int argc, char **argv) {
} |
just for the records:
Fedora release 29
gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6)
In file included from /usr/include/termios.h:25,
from kilo.c:40:
/usr/include/features.h:184:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
^~~~~~~
kilo.c: In function ‘editorRefreshScreen’:
kilo.c:953:19: warning: implicit declaration of function ‘time’; did you mean ‘tee’? [-Wimplicit-function-declaration]
if (msglen && time(NULL)-E.statusmsg_time < 5)
^~~~
tee
The text was updated successfully, but these errors were encountered: