You are not logged in.
Pages: 1
Hello All,
As many of you may be well-aware of, Arch Linux and C go hand in hand. And today I just found out that there's a new standard of C!
If that seems odd it's because I was a physics major who only took two CS courses and my professor was so old, gnu99 was the fancy new library.
So I can compile gcc fine with -std=c11 but I also saw that C11 introduces much more multithreading support and that to access them, I should use "#include <threads.h>" in my C files.
But when I did this, gcc kept telling me that the file threads.h did not exist. And it was not lying. My /usr/include (which I had no idea actually held the C libraries which makes things make a lot more sense now) does not have a threads.h but instead it has a thread_db.h which allows me to declare "thread_t tid;" in C files with the new standard.
So I have to ask, why is mine a different name? Every online example (the few there are) uses "#include <threads.h>" but I have to use "#include <thread_db.h>". Am I special you guys?
Offline
Moving to Programming and Scripting...
Offline
Lol my bad.
I was just wondering if my C install is different than others because of the different library name. Oddly enough, this is the only library I've ever had issues with.
Offline
/usr/include does not hold libraries, it holds header files which can be included. Libraries are in /usr/lib. Crazy naming huh?
Your header file names match mine. I don't know much about multithreading - I use it when I need to, but my background may come from ages well before this professor you speak of (Not that I'm old, just out of touch). But I usually use pthread.h (posix thread).
If you want to look for a threads.h, try `pkgfile threads.h`
Also, look *in* header files. Many that have similar names just end up sharing a "heritage" anyway. I just checked, and thread_db.h includes pthread.h. So thread_db *might* be some wrapper library for pthread (which make me more confident in just using pthread - I like wrappers on my candy, not on my libraries).
Also, reading the comments at the start of thread_db.h would tell you that it is a thread debugging library - for debugging pthread programs (which is a pain!). So thread_db is not what you want if you just want to *use* threading.
EDIT: after investigating I have to wonder if you are really looking at C examples ... or at C++ examples. Threads.h is a header file in glibmm which is the C++ API for glib.
EDIT again: I imagine thread_db.h is working for you because the example code you are using is for posix threads, which is included from thread_db.h. Are the functions you're using all look like pthread_*
Last edited by Trilby (2013-06-26 20:54:28)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Lol the library has the line "typedef pthread_t thread_t"
I think I got trolled or am incredibly dumb T_T
Edit: And I think you're right, I might be doing this for C++ code lol. I'm dumb.
Last edited by MutantJohn (2013-06-26 21:01:52)
Offline
glibc / gcc does not provides a complete c11 implementation yet.
http://gcc.gnu.org/projects/cxx0x.html
http://gcc.gnu.org/onlinedocs/libstdc++ … s.iso.200x
Last edited by progandy (2013-06-26 21:05:50)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
I'm dumb.
Nah, just new to multithreaded programming. You want to see dumb, check out threads that end in the dustbin. This is a useful thread with a good question.
Last edited by Trilby (2013-06-26 21:03:59)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
From http://gcc.gnu.org/onlinedocs/gcc/Standards.html
A fourth version of the C standard, known as C11, was published in 2011 as ISO/IEC 9899:2011. GCC has limited incomplete support for parts of this standard, enabled with -std=c11 or -std=iso9899:2011. (While in development, drafts of this standard version were referred to as C1X.)
Offline
Okay, so there's just no thread.h yet?
That's lame! I want to be the most current now!
And ty for the support <3
Offline
Pages: 1