NO

Author Topic: No support for '__declspec(thread)  (Read 1610 times)

Jimg

  • Guest
No support for '__declspec(thread)
« on: February 02, 2019, 04:32:10 AM »
I am a total C noob, bear with me---
I'm trying to compile an old Microsoft program (MTTTY).
I get the following error:
 warning #2208: No support for '__declspec(thread)'.
on this line:
 __declspec(thread) static DWORD dwOldStatus = 0;

I assume this is an old form of syntax that has been superseded, ( the program is from 1995), What is the correct way to code this?

Jimg

  • Guest
Re: No support for '__declspec(thread)
« Reply #1 on: February 02, 2019, 04:41:24 AM »
Of course, as soon as I posted I found the an option that solved it.

Project options/compiler/runtime library=multithreaded (LIB).

Sorry for troubling you all.   However, if this is not the correct solution, please let me know :)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: No support for '__declspec(thread)
« Reply #2 on: February 02, 2019, 05:11:28 PM »
Hi Jimg, welcome in PellesC community.
Just a short explanation.
The __declspec() storage class specifier is an MS custom extension supported in PellesC when MS extensions are enabled (see /Ze compiler switch for MS mode enable).
__declspec(thread) specify that the variable will exist only in local thread. To make sense for a local thread storage you should be compiling for a multithreaded application.
If you try to use it in a single threaded environment the compiler issues an error. To enable multithreaded environment you must use the /MT switch (as you made).
Starting with C11 standard revision a new storage class specifier is available: _Thread_local, which is fully equivalent the the MS proprietary __declspec(thread)
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Jimg

  • Guest
Re: No support for '__declspec(thread)
« Reply #3 on: February 02, 2019, 06:32:39 PM »
Thanks much for the explanation :)