Skip to content

Conversation

@chses9440611
Copy link
Contributor

There are two definitions of strdup in harness.h
and string2.h. This will cause a redefined error
when compile. Using macro #undef to undef the
strdup defined in string2.h:1291.

@jserv
Copy link
Contributor

jserv commented Feb 17, 2020

Since strdup-related work was contributed by @afcidk, I would defer to him.

@afcidk
Copy link
Collaborator

afcidk commented Feb 19, 2020

@chses9440611, may I ask your build environment and the string2.h source? Since I cannot reproduce the error on my machine

@chses9440611
Copy link
Contributor Author

chses9440611 commented Feb 19, 2020

@afcidk,
kernel version: 4.15.0-76-generic, Ubuntu 16.04 GNU/linux
gcc version: 7.4.0
redefintion location is at /usr/include/x86_64-linux-gnu/bits/string2.h:1291

@chses9440611
Copy link
Contributor Author

@afcidk, I think it's my own machine fault. For there exists a "string2.h" file under my /usr/include/x86_64-linux-gnu/bits/ , whcih will lead to redefinition error. I think most other machines won't have this problem. Should I close this pull request directly?

@afcidk
Copy link
Collaborator

afcidk commented Feb 19, 2020

The problem seems to lie in glibc version. string2.h is removed after glibc-2.26. The redefinition problem is caused by strdup inlines in string2.h. (It is removed in commit ae65d4f, so glibc version >= 2.26 should not see this problem)

I think we don't need the #ifdef strdup guard before #undef, maybe we could just leave

#undef strdup
#define strdup test_strdup

instead.

@afcidk
Copy link
Collaborator

afcidk commented Feb 19, 2020

@afcidk, I think it's my own machine fault. For there exists a "string2.h" file under my /usr/include/x86_64-linux-gnu/bits/ , whcih will lead to redefinition error. I think most other machines won't have this problem. Should I close this pull request directly?

Since we do not restrict glibc's version, I think this change is suitable.

@chses9440611
Copy link
Contributor Author

So, just modify the pull request or submit another pull request ?

@afcidk
Copy link
Collaborator

afcidk commented Feb 19, 2020

Modify the pull request. You can force push the revised commit.

@jserv
Copy link
Contributor

jserv commented Feb 19, 2020

Use git commit --amend and/or git rebase -i to rework commits.

@chses9440611 chses9440611 force-pushed the master branch 2 times, most recently from 2ed393b to 61d5f1c Compare February 19, 2020 07:06
If the glibc version < 2.26.There are two
definitions of strdup in harness.h and string2.h.
This will cause a redefined error when compile.
Using macro #undef to undef the strdup defined
in string2.h:1291.
@jserv jserv merged commit ab97f98 into sysprog21:master Feb 19, 2020
@jserv
Copy link
Contributor

jserv commented Feb 19, 2020

Thank @chses9440611 for contribution!

@chses9440611
Copy link
Contributor Author

Thank @jserv @afcidk, I got a good experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants