GtkText is deprecated and unsupported. It is known to be buggy. To use it, you must define the symbol
GTK_ENABLE_BROKEN
prior to including the GTK+ header files. Use GtkTextView instead.
Why am I getting an implicit declaration error for a predefined gtk function?
Question
I am trying to read text in from a file and insert that text into a text box.
This is the code I am using.
FILE *infile;
GdkFont *fixed_font;
infile = fopen("text.txt", "r");
fixed_font = gdk_font_load ("-misc-fixed-medium-r-*-*-*-140-*-*-*-*-*-*");
if (infile) {
char buffer[1024];
int nchars;
while (1)
{
nchars = fread(buffer, 1, 1024, infile);
gtk_text_insert(view, fixed_font, NULL, NULL, buffer, nchars);
if (nchars < 1024)
break;
}
fclose (infile);
These are my includes
#include <gtk/gtk.h>
#include <gtk/gtktext.h>
When I compile I get this warning:
warning: implicit declaration of function ‘gtk_text_insert’
I have read on this forum and others that implicit declaration errors come from using functions before they are declared. However, gtk_text_insert()
is included in the header file so how can this be implicit?
I am using the following software:
gtk version 2.20.1
Red Hat Enterprise Linux Server release 6.5
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow