Condition variables

This is a discussion on Condition variables within the Windows Programming forums, part of the Platform Specific Boards category; I was trying to use condition variables on Windows, but I get a compiler error. I believe that it is ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    96

    Condition variables

    I was trying to use condition variables on Windows, but I get a compiler error.
    I believe that it is because my compiler (MinGW) doesn't have the definitions yet, but I'm not sure.

    Anyways has anyone used condition variables on Windows Vista and gotten it to work with MinGW? I don't think I can just add the definitions in my headers can I? Because the linker won't be able to find the symbols in kernel32.lib right? Probably doesn't exist in the kernel32.dll either.....


    BTW docs on condition variables are here for those interested.

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Any reason to use the over say CriticalSection's, or semaphores?
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The symbols should be in the kernel32.lib and kernel32.dll.

    You will need the correct definition in the header-file. I think all you actually need is a Windows SDK with the relevant "windows.h" [and it's sub-includes].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    You can put the declarations in the header, but you shouldn't. Include the proper header (windows.h) and link with the correct library, and there you have it.
    It should be included in the latest SDK.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    Unfortunately, I don't think that MinGW "works" with the platform sdk, due to ms-compiler specific extensions.

    The win32api for MinGW can be downloaded here:
    http://sourceforge.net/project/showf...ease_id=564368

    But the source is maintained over at cygwin here:
    http://cygwin.com/cgi-bin/cvsweb.cgi...y=date#dirlist

    I don't see support condition variables, but you could support them yourself. First you'll have need to download the latest Platform SDK so you can get the proper definitions for CONDITION_VARIABLE.
    Web Install
    DVD ISO
    Hopefully, someone who already has this will post the definition

    Then you can define all the condition variable api's as global function pointers, and set them using GetProcAddress().

    Another alternative is to switch to a microsoft compiler and use the latest platform sdk directly.

    gg

  6. #6
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    mingw has its own version of the sdk available as a package.

    Then again, with VS 2005 being free to hobyists why not use that?
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    96
    Quote Originally Posted by abachler View Post
    Any reason to use the over say CriticalSection's, or semaphores?
    Yes. Critical sections (Mutexes) aren't condition variables, neither are semaphores....

    The problem with using condition vars on Windows for now is that they are Windows 6 (Vista/Server 2008) only.
    I believe that Boost implemented condition vars with mutexes, and semaphores on the Windows platform since pre-Windows 6 kernels don't have condition vars.
    Which I probably will have to do, but I would like to see if I can get the "native" ones to work.

    Quote Originally Posted by Codeplug View Post
    Unfortunately, I don't think that MinGW "works" with the platform sdk, due to ms-compiler specific extensions.
    Hmm I'm using the SDK that comes with MinGW.
    But I never thought of using the MS SDK with MinGW.
    I guess I could try that. Heh.

    Quote Originally Posted by Codeplug View Post
    Another alternative is to switch to a microsoft compiler and use the latest platform sdk directly.
    Quote Originally Posted by abachler View Post
    Then again, with VS 2005 being free to hobyists why not use that?
    VS 2008 is free too.


    I've tried using the MS compiler, but I had too many issues with it
    Building DLL's is a pain (you must do non-portable things), plus it doesn't support standard language keywords that I need (and, or, etc.). Otherwise I would use it.....

  8. #8
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    >> But I never thought of using the MS SDK with MinGW. I guess I could try that.
    It won't work with MinGW. Having the MS SDK on hand is good for extracting any definitions that aren't in the MinGW Win32API headers.

    gg

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,313
    plus it doesn't support standard language keywords that I need (and, or, etc.).
    Interesting observation. According to the C++ Standard, those keywords should be available and thus not defined as macro names in <ciso646>, but a little experimentation with VS 2005 shows that if you #include <ciso646>, those keywords will work.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Quote Originally Posted by sethjackson View Post
    Building DLL's is a pain (you must do non-portable things),
    Huh? How so? I've been building DLLs for a long and it's a snap due to Visual Studio.

    ...plus it doesn't support standard language keywords that I need (and, or, etc.). Otherwise I would use it.....
    I can't believe anyone is using those... What's wrong with && and ||?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,313
    I can't believe anyone is using those... What's wrong with && and ||?
    Apparently, some characters like & and | are not easily typed on certain keyboards.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by laserlight View Post
    Apparently, some characters like & and | are not easily typed on certain keyboards.
    Like Swedish one where you use Alt-GR 7..0 to give some of those - and I'm sure there are languages/countries where those are worse. Not to mention scandinavian [for example] 7-bit ASCII [yes, I know, it's again something OLD] which makes all the
    Code:
    |, {}, [] and \
    into letters , , and their uppercase variations [not necessarily in respective order].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Quote Originally Posted by matsp View Post
    Like Swedish one where you use Alt-GR 7..0 to give some of those...
    That's not necessarily bad, though. It's absolutely fine.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Registered User
    Join Date
    Aug 2005
    Posts
    96
    Quote Originally Posted by Elysia View Post
    Huh? How so? I've been building DLLs for a long and it's a snap due to Visual Studio.
    I need import libs. You have to write __declspec(dllexport) before everything you want
    to export. Yuck, and unnecessary with MinGW (GCC).

    Quote Originally Posted by Elysia View Post
    I can't believe anyone is using those... What's wrong with && and ||?
    Well there is at least one person on earth using those, me.
    See above posts for more reasons.

  15. #15
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Quote Originally Posted by sethjackson View Post
    I need import libs.
    Need import libs? I don't think I understood that one.

    Quote Originally Posted by sethjackson View Post
    You have to write __declspec(dllexport) before everything you want to export. Yuck, and unnecessary with MinGW (GCC).
    That or use a .def file. That's standard way. And it isn't "yuck." It's a very handy way to actually export functions and classes and variables.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM
  2. Best way to avoid using global variables
    By Canadian0469 in forum C++ Programming
    Replies: 7
    Last Post: 12-18-2008, 11:02 AM
  3. Remotely Creating Variables
    By Rajin in forum C++ Programming
    Replies: 1
    Last Post: 04-26-2005, 11:20 PM
  4. pthread condition variables
    By jbsloan in forum C Programming
    Replies: 1
    Last Post: 03-08-2005, 11:45 AM
  5. Declaring an variable number of variables
    By Decrypt in forum C++ Programming
    Replies: 8
    Last Post: 02-27-2005, 03:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21