Thread: A few questions

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    144

    A few questions

    1. The standard allows multibyte character sets. What character set is most commonly used with C? Is it UTF-8?

    2. Does anyone actually use trigraphs these days? Or does that only apply to obscure, old machines?

    3. The functions in the standard library are not re-entrant. Yet, my program might access the library at the same time as another process on the same machine. Does the library have separate static storage *for each thread* ?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    1. The standard allows multibyte character sets. What character set is most commonly used with C? Is it UTF-8?
    C is on so many different kinds of platforms, it's hard to say what would be "common".
    You might get a useful answer if you restrict yourself to say "Linux console" programming or "Win32 GUI" programming.

    2. Does anyone actually use trigraphs these days? Or does that only apply to obscure, old machines?
    Digraphs and trigraphs - Wikipedia, the free encyclopedia

    3. The functions in the standard library are not re-entrant. Yet, my program might access the library at the same time as another process on the same machine.
    Does the library have separate static storage *for each thread* ?
    This is a feature of your OS, providing separate address spaces to each process.
    But since you said threads, which share the same address space, then you would need to be mindful of concurrency issues.

    And it's only some of the functions which are non-reentrant, not all of them.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Digraphs and trigraphs are sometimes used by some programmers who are not native english speakers, and who use keyboards that do not support all characters in C's basic character set.

    Other than that, the only places where I've seen digraphs and trigraphs deliberately used is in compiler stress tests or benchmarks. I've seen them used accidentally quite a few times though.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    A function like strtok is not re-entrant, but then the standard library doesn't include threads. If something like pthreads is used then posix includes a matching strtok_r that is re-entrant. Don't know about C11, which do add threading to the standard library.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. got some C++ questions, please help
    By lqq889 in forum C++ Programming
    Replies: 6
    Last Post: 03-09-2010, 03:04 AM
  2. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  3. c++ questions
    By jmarsh56 in forum C++ Programming
    Replies: 3
    Last Post: 05-03-2006, 06:15 AM
  4. Two Questions (They never end... -,-)
    By Blackroot in forum C++ Programming
    Replies: 7
    Last Post: 01-16-2006, 02:06 PM
  5. 2 questions
    By myUserName in forum C++ Programming
    Replies: 10
    Last Post: 02-19-2003, 09:52 PM