Skip to content

OS X: Two Small Code Issues Trigger Build Warnings #2

@TurtleWilly

Description

@TurtleWilly

Building on a bit older version of (Mac) OS X we'll see a few warnings:

$ make
cc  -o lc lc.c
lc.c:22:9: warning: 'DIRSIZ' macro redefined [-Wmacro-redefined]
#define DIRSIZ MAXNAMLEN
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/dir.h:86:9: note: previous definition is here
#define DIRSIZ(dp) \
        ^
lc.c:268:16: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
                while (*p1++ = *p2++)
                       ~~~~~~^~~~~~~
lc.c:268:16: note: place parentheses around the assignment to silence this warning
                while (*p1++ = *p2++)
                             ^
                       (            )
lc.c:268:16: note: use '==' to turn this assignment into an equality comparison
                while (*p1++ = *p2++)
                             ^
                             ==
2 warnings generated.

Both issues should be easy to fix. :)

Ignoring the warnings: the generated executable seems to work fine from what I can tell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions