Issue with strings.h and application that defines its own "mcpy" function. #845
Closed
fswarbrick
started this conversation in
Porting
Replies: 1 comment 11 replies
-
|
Interesting, it's guarded out for xlclang, but not clang: FYI @perry-ca One solution is to use a trick like this: https://github.com/ibmruntimes/zoslib/blob/zopen2/include/stdio.h#L33-L36 |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
So I am porting JOE (Joe's Own Editor) and running in to an annoyance. JOE defines a function named mcpy. When a file that includes strings.h and has its own mcpy() declaration is compiled it gets an error that there are
conflicting types for 'mcpy'. This is because strings.h contains a declaration for a function called mcpy.If the file that includes strings.h is compiled with no special macros defined at compile time this error does not occur. However, it looks like ZOT includes both
-D_XOPEN_SOURCE=600and-D_ALL_SOURCE, which in turn sets the __UU macro. If the __UU macro is defined then the declaration of mcpy is done when strings.h is included.The first question I have is what is the point of strings.h declaring mcpy. It does not appear to be a member in the z/OS runtime libraries. I wonder if it is a legacy declaration in strings.h that is no longer required. I realize this would be a z/OS base issue, not a ZOT issue.
In any case, any thoughts on the best way to get around this? The way I've done it at this point is to copy /usr/include/strings.h in to the application's source directory, and then remove the declaration. With this and a few other minor changes I have gotten JOE to function.
If you want to try it yourself, here is a tiny test program that demonstrates the issue.
And compile with
clang -D_XOPEN_SOURCE=600 -D_ALL_SOURCE memcp.c(obviously replacing clang with whatever C compiler you are using)You will get results looking something like this:
Without specifying the two macro definitions it compiles fine (but the link-edit fails because mcpy does not exist).
Beta Was this translation helpful? Give feedback.
All reactions