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;








0















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?










share|improve this question




























    0















    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?










    share|improve this question
























      0












      0








      0








      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?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 20:49









      user149408user149408

      2,2471129




      2,2471129






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer























          • 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











          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
          );



          );













          draft saved

          draft discarded


















          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









          0














          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.






          share|improve this answer























          • 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















          0














          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.






          share|improve this answer























          • 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













          0












          0








          0







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript