tcpdump mailing list archives

#define strdup _strdup


From: Denis Ovsienko <denis () ovsienko info>
Date: Fri, 6 Sep 2024 09:43:22 +0100

Hello all.

One thing caught my eye in tcpdump netdissect-stdinc.h:

#ifdef _MSC_VER
  /*
   * Microsoft tries to avoid polluting the C namespace with UN*Xisms,
   * by adding a preceding underscore; we *want* the UN*Xisms, so add
   * #defines to let us use them.
   */
  #define isatty _isatty
  #define stat _stat
  #define strdup _strdup
[...]
  /*
   * If <crtdbg.h> has been included, and _DEBUG is defined, and
   * __STDC__ is zero, <crtdbg.h> will define strdup() to call
   * _strdup_dbg().  So if it's already defined, don't redefine
   * it.
   */
  #ifndef strdup
    #define strdup _strdup
  #endif

One issue here is that the second #define looks like unintended dead
code.  Another is that the first #define, which does not have an #ifdef
guard, does not produce a compiler warning, at least the string
"strdup" does not appear in the output of any current Windows builds on
Appveyor.  This hints that strdup is not originally defined and the
comment and the second #define are stale.  libpcap portability.h has
only the second #define.

That's as far as I can reason about this -- I do not use Windows.

-- 
    Denis Ovsienko
_______________________________________________
tcpdump-workers mailing list -- tcpdump-workers () lists tcpdump org
To unsubscribe send an email to tcpdump-workers-leave () lists tcpdump org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s


Current thread: