No support for '__declspec(thread)

Started by Jimg, February 02, 2019, 04:32:10 AM

Previous topic - Next topic

Jimg

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

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

frankie

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