why QCC doesn't support input_line() ?

Hi,all
I want use input_lint() fuction to read lines from an text file. So I use
the following example:

#include <stdlib.h>
#include <stdio.h>

#define SIZ 256

int _input_line_max

int main(void)
{
FILE *fp;
char *p, buf[SIZ];

fp=fopen("./a.cfg",“r”);
_input_line_max = 25;

while( ( p=input_line( fp, buf, SIZ ) ) != NULL )
{
printf( “%s\n”,buf);
}

return EXIT SUCCESS;
}

Then I compile the file by using:
qcc mytest.c -o mytest
It show the following message:
warning: assignment makes pointer from integer without a cast

It seems that input_line() return an integer instead char* pointer

I change mytest.c to mytest.cpp, and then compile it with,
QCC mytest.cpp -o mytest
It show the following message:
mytest.cpp:16: implicit declaration of function ‘int input_line(…)’
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33

So I have two question:

  1. why doesn’t input_line() return a char * pointer just as it is
    described in library Reference
  2. why doesn’t QCC supprot this fuction

ps. all my work is under QNX6.1

lpber wrote:

Hi,all
I want use input_lint() fuction to read lines from an text file. So I use
the following example:

#include <stdlib.h
#include <stdio.h

#define SIZ 256

int _input_line_max

int main(void)
{
FILE *fp;
char *p, buf[SIZ];

fp=fopen("./a.cfg",“r”);
_input_line_max = 25;

while( ( p=input_line( fp, buf, SIZ ) ) != NULL )
{
printf( “%s\n”,buf);
}

return EXIT SUCCESS;
}

Then I compile the file by using:
qcc mytest.c -o mytest
It show the following message:
warning: assignment makes pointer from integer without a cast

It seems that input_line() return an integer instead char* pointer

No, that is because the compiler couldn’t find a prototype for the
function hence it default to a function returning int. If you bump up
the warning level I’m pretty sure you would see a warning about
prototype not found

I change mytest.c to mytest.cpp, and then compile it with,
QCC mytest.cpp -o mytest
It show the following message:
mytest.cpp:16: implicit declaration of function ‘int input_line(…)’
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33

That proves my theory :wink: C++ is more senstive to function not being
defined.


So I have two question:

  1. why doesn’t input_line() return a char * pointer just as it is
    described in library Reference
  2. why doesn’t QCC supprot this fuction

ps. all my work is under QNX6.1

Looking at the header file stdio.h the prototype for input_line is
surrounded by ifdef:

#ifdef _this_belongs_in_a_private_qnx_header

#endif

So I’m not sure what the solution is. Personally since this is a QNX4
function I would not use it all together. (The documentation says that
QNX4 function should not be used in Neutrino expect for porting
consideration)




Mario Charest wrote:

lpber wrote:

Hi,all
I want use input_lint() fuction to read lines from an text file. So
I use
the following example:

#include <stdlib.h
#include <stdio.h

#define SIZ 256

int _input_line_max

int main(void)
{
FILE *fp;
char *p, buf[SIZ];

fp=fopen("./a.cfg",“r”);
_input_line_max = 25;

while( ( p=input_line( fp, buf, SIZ ) ) != NULL )
{
printf( “%s\n”,buf);
}

return EXIT SUCCESS;
}

Then I compile the file by using:
qcc mytest.c -o mytest
It show the following message:
warning: assignment makes pointer from integer without a cast

It seems that input_line() return an integer instead char* pointer


No, that is because the compiler couldn’t find a prototype for the
function hence it default to a function returning int. If you bump up
the warning level I’m pretty sure you would see a warning about
prototype not found


I change mytest.c to mytest.cpp, and then compile it with,
QCC mytest.cpp -o mytest
It show the following message:
mytest.cpp:16: implicit declaration of function ‘int
input_line(…)’
cc: /usr/lib/gcc-lib/ntox86/2.95.2/cc1plus error 33


That proves my theory > :wink: > C++ is more senstive to function not being
defined.


So I have two question:

  1. why doesn’t input_line() return a char * pointer just as it is
    described in library Reference
  2. why doesn’t QCC supprot this fuction

ps. all my work is under QNX6.1


Looking at the header file stdio.h the prototype for input_line is
surrounded by ifdef:

#ifdef _this_belongs_in_a_private_qnx_header

#endif

So I’m not sure what the solution is. Personally since this is a QNX4
function I would not use it all together. (The documentation says that
QNX4 function should not be used in Neutrino expect for porting
consideration)

Use fgets instead.