Ticket #281 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

implicit declaration of function `strdup'

Reported by: songcw@… Owned by: buglog@…
Priority: normal Milestone:
Component: openmoko-applicationmanager Version: current svn head
Severity: normal Keywords:
Cc: buglog@… Blocked By:
Blocking: Estimated Completion (week):
HasPatchForReview: PatchReviewResult:
Reproducible:

Description

In the openmoko-appmanager, in the file ipkgapi.c, it includes the strings.h,
but it still report as that:
ipkgapi.c:415: warning: implicit declaration of function `strdup'

How to resolve it?

Change History

comment:1 Changed 6 years ago by philippedeswert@…

the include string.h has the following definition:

#if defined USE_SVID
defined USE_BSD defined USE_XOPEN_EXTENDED

/* Duplicate S, returning an identical malloc'd string. */
extern char *strdup (const char *s)

THROW attribute_malloc nonnull ((1));

#endif

For some reason none of those defines is used, AFAIK USE_XOPEN_EXTENDED should
be. Maybe someone can clear up that issue for us?

So if you do the following instead of just including <string.h> it works:

#define USE_XOPEN_EXTENDED
#include <string.h>

Anyway IMHO that is a temporary workaround.

comment:2 Changed 6 years ago by songcw@…

  • Status changed from new to closed
  • Resolution set to fixed

It seems that the strdup is not a standard function in c99. Before find a better
way to resolve it, it will use the USE_XOPEN_EXTENDED macro temporary.

Thanks Philippe De Swert.

comment:3 Changed 6 years ago by philippedeswert@…

You're welcome. Glad to have been of help and to see somebody caring about code
quality.

Note: See TracTickets for help on using tickets.