473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

strnlen() warning

Mat
Hi all.
This function is a GNU extension ok... so pls dont start with "this is
not standard C", "go to comp.*.unix"... here I have more probability to
get a good reply.
BTW, when I compile my app I get:

warning: implicit declaration of function `strnlen'

And I hate this :)
Ok, it's only a stupid warning in this case but I would like to know
the right define that allow me to include the standard prototype of the
function.
>From string.h :
#ifdef __USE_GNU
extern size_t strnlen (__const char *__string, size_t __maxlen)
__THROW __attribute_pure__;
#endif

But if I try to compile with -D__USE_GNU the warning remains...
Someone can help me?

Bye,
-Mat-

P.S.
I have the same problem with crypt() ...

Jul 27 '06 #1
8 8168
Mat wrote:
This function is a GNU extension ok... so pls dont start with "this is
not standard C", "go to comp.*.unix"... here I have more probability to
get a good reply.
BTW, when I compile my app I get:

warning: implicit declaration of function `strnlen'

And I hate this :)
Ok, it's only a stupid warning in this case but I would like to know
the right define that allow me to include the standard prototype of the
function.
>>From string.h :

#ifdef __USE_GNU
extern size_t strnlen (__const char *__string, size_t __maxlen)
__THROW __attribute_pure__;
#endif

But if I try to compile with -D__USE_GNU the warning remains...
Someone can help me?
Sounds like your include paths are messed up. Are you sure you are
getting the string.h that corresponds to the GNU extensions? One trick
is to have the compiler leave the interim files around so you can see
what the source-and-headers expand to during the pre-processor phase.

And, yes, this is surely off-topic here. I'm sure one of the GNU
newsgroups can help you. Follow-ups set.
Jul 27 '06 #2

"Mat" <he***********@gmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
Hi all.
This function is a GNU extension ok... so pls dont start with "this is
not standard C", "go to comp.*.unix"... here I have more probability to
get a good reply.
This newsgroup is about ISO standard C. So why would
you expect more probability of a good reply here rather
than in a topical group?

BTW, when I compile my app I get:

warning: implicit declaration of function `strnlen'
This means you've called the function 'strnlen()' with
no prototype in scope.
>
And I hate this :)
So provide a prototype. If this function is provided by
your implementation, I'd expect it would also provide a
header which declares it. Failing that, find out its
signature and declare it yourself.
Ok, it's only a stupid warning in this case
Warnings are there for a reason. Don't disregard them
or consider them 'stupid'.
>but I would like to know
the right define that allow me to include the standard prototype of the
function.
There is not function 'strnlen()' in standard C. So of course
it cannot have a 'standard prototype'.
>
>>From string.h :

#ifdef __USE_GNU
extern size_t strnlen (__const char *__string, size_t __maxlen)
__THROW __attribute_pure__;
#endif
OK there's the prototype (looks like it uses some nonstandard
keywords too).
>
But if I try to compile with -D__USE_GNU the warning remains...
Someone can help me?
You're seeing an issue with your compiler. It's not a language
problem. You can get the best help with this on a GNU newsgroup,
mailing list or web site.
Bye,
-Mat-

P.S.
I have the same problem with crypt() ...
Neither is 'crypt()' part of standard C.

-Mike
Jul 27 '06 #3
Mat schrieb:
Hi all.
This function is a GNU extension ok... so pls dont start with "this is
not standard C", "go to comp.*.unix"... here I have more probability to
get a good reply.
BTW, when I compile my app I get:

warning: implicit declaration of function `strnlen'

And I hate this :)
Ok, it's only a stupid warning in this case but I would like to know
the right define that allow me to include the standard prototype of the
function.
>>From string.h :

#ifdef __USE_GNU
extern size_t strnlen (__const char *__string, size_t __maxlen)
__THROW __attribute_pure__;
#endif

But if I try to compile with -D__USE_GNU the warning remains...
Someone can help me?
It definitly is offtopic here, you had better asked in a GNU/gcc newgroups.

By short googling I found out that you have to use -D_GNU_SOURCE.

--
Thomas
Jul 27 '06 #4
Mat

Thomas J. Gritzan wrote:
By short googling I found out that you have to use -D_GNU_SOURCE.
Perfect, thanks Thomas.
I googled before but I didnt find this.

Jul 27 '06 #5
Mat

Mike Wahler wrote:
This newsgroup is about ISO standard C. So why would
you expect more probability of a good reply here rather
than in a topical group?
Because most of the "topical groups" are almost abandoned.
Look, got 3 replies in less then 10 mins and the solution.
warning: implicit declaration of function `strnlen'
This means you've called the function 'strnlen()' with no prototype in scope.
Hehe, yes :)
This is why I wrote the first post.
Ok, it's only a stupid warning in this case
Warnings are there for a reason. Don't disregard them
or consider them 'stupid'.
Sure, that's why I wrote "in this case".
I didn't posted the test up but it's a trivial code sample for strnlen.
There is not function 'strnlen()' in standard C. So of course
it cannot have a 'standard prototype'.
There is more then one standard, as I wrote before this is a GNU
extension.
Dont repeat again it's OT, I know it.
Neither is 'crypt()' part of standard C.
Yes, it's not part of standard C :)

Jul 27 '06 #6
Mat wrote:
Hi all.
This function is a GNU extension ok... so pls dont start with "this is
not standard C", "go to comp.*.unix"... here I have more probability to
get a good reply.
Go to a GNU group then.
BTW, when I compile my app I get:

warning: implicit declaration of function `strnlen'

And I hate this :)
Ok, it's only a stupid warning in this case but I would like to know
the right define that allow me to include the standard prototype of the
function.
No, the warning is not stupid. It shows a serious defect.
>>From string.h :

#ifdef __USE_GNU
extern size_t strnlen (__const char *__string, size_t __maxlen)
__THROW __attribute_pure__;
#endif

But if I try to compile with -D__USE_GNU the warning remains...
Someone can help me?
If defining __USE_GNU does not help then ask in a GNU group.
Bye,
-Mat-

P.S.
I have the same problem with crypt() ...
So ask somewhere that crypt is topical.

Why should anyone help since you know this is the wrong place?
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Jul 27 '06 #7
"Mat" <he***********@gmail.comwrites:
This function is a GNU extension ok... so pls dont start with "this is
not standard C", "go to comp.*.unix"... here I have more probability to
get a good reply.
This is not standard C. Try gnu.gcc.help.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 27 '06 #8
On Thu, 27 Jul 2006 08:33:43 -0700, Mat wrote:
>
Thomas J. Gritzan wrote:
>By short googling I found out that you have to use -D_GNU_SOURCE.

Perfect, thanks Thomas.
I googled before but I didnt find this.
You didn't need google. If you had traced the origins of __USE_GNU you
would have found it, as well as _GNU_SOURCE, in /usr/include/features.h.
That's an informative header for understanding Unix and Linux standard
support. In particular, _FOO_SOURCE is the typical way to expose
standard library functions in Unix environments.

In any event, this group was certainly the wrong place to come to. You
would most certainly have gotten a correct and far more helpful answer in
either comp.unix.programmer or comp.os.linux.development.apps. In the
future, know that comp.unix.programmer is extremely helpful and just as
prompt as comp.lang.c. Also, that group is also far more flexible w.r.t
topicality, maybe because "Unix" is a far more fuzzy topic.

Your post generated 5 responses w/o an answer or possibly w/ misleading
information (at least, misleading to your efforts and edification), and a
single one w/ the answer. You didn't take _our_ needs and wants into
account when deciding which group to post your question in. And maybe
that's the most important point.

Jul 27 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bas Wassink | last post by:
Hello there, I'm having trouble understanding a warning produced by 'splint', a code-checker. The warning produced is: keywords.c: (in function keyw_get_string) keywords.c:60:31: Released...
3
by: Bill Burris | last post by:
How do I find what is causing this warning from the Linker? If I use /NODEFAULTLIB I get hundreds of undefined symbols. LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other...
3
by: DJTN | last post by:
I'm getting the following error when I try to compile my setup project in VS 2002. I have re-installed the .net framework 1.1 and it didnt solve the problem. WARNING: Unable to find dependency...
1
by: spanov | last post by:
i've got problem installing python-2.3.5 from sources on FreeBSD 5.3 root@server# ./configure > conf_log configure: WARNING: curses.h: present but cannot be compiled configure: WARNING:...
0
by: Manish | last post by:
PHP INI File Setting ------------------------------------------------------------------------------------------------------------------ error_reporting = E_ALL & ~E_NOTICE No warning message are...
5
by: Peter Ritchie [C# MVP] | last post by:
I've purposely been ignoring a CA2122 warning in some C++ interop code I've been working on for quite some time. I've just recently had the cycles to investigate the warning. The warning message...
1
by: Ian | last post by:
I've just discovered the msclr::lock class in the C++ Support Library online documentation. This seems like a much cleaner way to implement thread protection than using...
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
4
by: cody | last post by:
It is possible to declare and use/instantiate a class with a uninitialized readonly field without even a compiler warning. Why don't I get warnings? public class Stuff { public readonly int a;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.