How to test if pthread_setname_np() is available on my platformWhy should one bother with preprocessor directives?Combining C++ and C - how does #ifdef __cplusplus work?Defining Bit-Flags Using #define in C++Does SASS have gotchas like the C preprocessor?Is Pthread library actually a user thread solution?Cross-platform access to C constantsTest if preprocessor symbol is defined inside macroHow to detect GCC threading model with preprocessor?Test Availability of x_np pthread Functions - C/C++How is the POSIX threading api versioned and has it been updated since 1995?
What happens to matryoshka Mordenkainen's Magnificent Mansions?
60s (or earlier) SF short story with FTL Travel using electron psychology aka addiclenendar technology
Can Ghost kill White Walkers or Wights?
CRT Oscilloscope - part of the plot is missing
Casual versus formal jacket
Catholic vs Protestant Support for Nazism in Germany
Python password manager
Upside-Down Pyramid Addition...REVERSED!
What actually is the vector of angular momentum?
Reconstruct a matrix from its traces
How to give very negative feedback gracefully?
My ID is expired, can I fly to the Bahamas with my passport?
Would "lab meat" be able to feed a much larger global population
Besides the up and down quark, what other quarks are present in daily matter around us?
What does a yield inside a yield do?
Short story with physics professor who "brings back the dead" (Asimov or Bradbury?)
I caught several of my students plagiarizing. Could it be my fault as a teacher?
Does this article imply that Turing-Computability is not the same as "effectively computable"?
Did we get closer to another plane than we were supposed to, or was the pilot just protecting our delicate sensibilities?
In a vacuum triode, what prevents the grid from acting as another anode?
How to improve/restore vintage Peugeot bike, or is it even worth it?
Accidentally deleted the "/usr/share" folder
How can I support myself financially as a 17 year old with a loan?
For a benzene shown in a skeletal structure, what does a substituent to the center of the ring mean?
How to test if pthread_setname_np() is available on my platform
Why should one bother with preprocessor directives?Combining C++ and C - how does #ifdef __cplusplus work?Defining Bit-Flags Using #define in C++Does SASS have gotchas like the C preprocessor?Is Pthread library actually a user thread solution?Cross-platform access to C constantsTest if preprocessor symbol is defined inside macroHow to detect GCC threading model with preprocessor?Test Availability of x_np pthread Functions - C/C++How is the POSIX threading api versioned and has it been updated since 1995?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Some POSIX thread implementations define pthread_setname_np()
to set a display name for a thread. However, this seems to be a nonstandard extension.
How can I test (via preprocessor directives) if the function is available on the platform I am building for, and skip the call if it is not?
pthreads c-preprocessor
add a comment |
Some POSIX thread implementations define pthread_setname_np()
to set a display name for a thread. However, this seems to be a nonstandard extension.
How can I test (via preprocessor directives) if the function is available on the platform I am building for, and skip the call if it is not?
pthreads c-preprocessor
add a comment |
Some POSIX thread implementations define pthread_setname_np()
to set a display name for a thread. However, this seems to be a nonstandard extension.
How can I test (via preprocessor directives) if the function is available on the platform I am building for, and skip the call if it is not?
pthreads c-preprocessor
Some POSIX thread implementations define pthread_setname_np()
to set a display name for a thread. However, this seems to be a nonstandard extension.
How can I test (via preprocessor directives) if the function is available on the platform I am building for, and skip the call if it is not?
pthreads c-preprocessor
pthreads c-preprocessor
asked Mar 22 at 20:49
user149408user149408
2,2471129
2,2471129
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can't test for a function existence with the preprocessor.
That kind of thing is exactly why people use build configuration tools like autoconf. The idea is that you have you build environment define a preprocessor macro like HAVE_PTHREAD_SETNAME_NP
only if such a function exists, then your code can just test for that macro with #ifdef
.
That’s about as far as I got, I wanted to know if there’s e.g. some definition in the header file that gets set (by convention) if that function is available—but apparently there isn’t.
– user149408
Mar 23 at 18:22
No, however you could perhaps test for particular C libraries and versions thereof (eg.#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR >= 12)
.
– caf
Mar 24 at 22:40
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307572%2fhow-to-test-if-pthread-setname-np-is-available-on-my-platform%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can't test for a function existence with the preprocessor.
That kind of thing is exactly why people use build configuration tools like autoconf. The idea is that you have you build environment define a preprocessor macro like HAVE_PTHREAD_SETNAME_NP
only if such a function exists, then your code can just test for that macro with #ifdef
.
That’s about as far as I got, I wanted to know if there’s e.g. some definition in the header file that gets set (by convention) if that function is available—but apparently there isn’t.
– user149408
Mar 23 at 18:22
No, however you could perhaps test for particular C libraries and versions thereof (eg.#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR >= 12)
.
– caf
Mar 24 at 22:40
add a comment |
You can't test for a function existence with the preprocessor.
That kind of thing is exactly why people use build configuration tools like autoconf. The idea is that you have you build environment define a preprocessor macro like HAVE_PTHREAD_SETNAME_NP
only if such a function exists, then your code can just test for that macro with #ifdef
.
That’s about as far as I got, I wanted to know if there’s e.g. some definition in the header file that gets set (by convention) if that function is available—but apparently there isn’t.
– user149408
Mar 23 at 18:22
No, however you could perhaps test for particular C libraries and versions thereof (eg.#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR >= 12)
.
– caf
Mar 24 at 22:40
add a comment |
You can't test for a function existence with the preprocessor.
That kind of thing is exactly why people use build configuration tools like autoconf. The idea is that you have you build environment define a preprocessor macro like HAVE_PTHREAD_SETNAME_NP
only if such a function exists, then your code can just test for that macro with #ifdef
.
You can't test for a function existence with the preprocessor.
That kind of thing is exactly why people use build configuration tools like autoconf. The idea is that you have you build environment define a preprocessor macro like HAVE_PTHREAD_SETNAME_NP
only if such a function exists, then your code can just test for that macro with #ifdef
.
answered Mar 23 at 3:36
cafcaf
194k27254395
194k27254395
That’s about as far as I got, I wanted to know if there’s e.g. some definition in the header file that gets set (by convention) if that function is available—but apparently there isn’t.
– user149408
Mar 23 at 18:22
No, however you could perhaps test for particular C libraries and versions thereof (eg.#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR >= 12)
.
– caf
Mar 24 at 22:40
add a comment |
That’s about as far as I got, I wanted to know if there’s e.g. some definition in the header file that gets set (by convention) if that function is available—but apparently there isn’t.
– user149408
Mar 23 at 18:22
No, however you could perhaps test for particular C libraries and versions thereof (eg.#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR >= 12)
.
– caf
Mar 24 at 22:40
That’s about as far as I got, I wanted to know if there’s e.g. some definition in the header file that gets set (by convention) if that function is available—but apparently there isn’t.
– user149408
Mar 23 at 18:22
That’s about as far as I got, I wanted to know if there’s e.g. some definition in the header file that gets set (by convention) if that function is available—but apparently there isn’t.
– user149408
Mar 23 at 18:22
No, however you could perhaps test for particular C libraries and versions thereof (eg.
#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR >= 12)
.– caf
Mar 24 at 22:40
No, however you could perhaps test for particular C libraries and versions thereof (eg.
#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR >= 12)
.– caf
Mar 24 at 22:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307572%2fhow-to-test-if-pthread-setname-np-is-available-on-my-platform%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown