Search:

Type: Posts; User: christop

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    1
    Views
    200

    I imagine it would be difficult if not impossible...

    I imagine it would be difficult if not impossible for the assert function/macro to do such a thing. You could do something like this, though:



    assert(a == b || (fprintf(stderr, "a is %d\nb is...
  2. Replies
    9
    Views
    320

    I'm on Linux Mint 19.3 with GCC 9.3.0, and I can...

    I'm on Linux Mint 19.3 with GCC 9.3.0, and I can confirm it happens for me too. I'm trying to find any undefined behavior in the code but can't so far. Definitely looks like a bug in GCC 9.
  3. Replies
    125
    Views
    5,151

    That sounds like a distro that I'd avoid if they...

    That sounds like a distro that I'd avoid if they have such egregious bugs in their C library. Do you recall which distro it was? There's a lot of software out there that assumes it can safely pass a...
  4. Replies
    125
    Views
    5,151

    In default_allocator, you can simplify the...

    In default_allocator, you can simplify the allocation line to this:



    tmp = realloc( ptr, get );


    because realloc will allocate new memory if the pointer is null.

    Also, you can remove if...
  5. Replies
    20
    Views
    660

    They are also already written and work quite...

    They are also already written and work quite well.

    Something something about reinventing the wheel.
  6. Replies
    17
    Views
    1,245

    The warnings about casting to void* in printf...

    The warnings about casting to void* in printf statements are not ignorable. Passing in the wrong pointer type (i.e., not a void pointer) has undefined behavior. Some architectures even have different...
  7. Thread: Unions...

    by christop
    Replies
    8
    Views
    904

    Indeed. Some systems might have only one...

    Indeed. Some systems might have only one floating-point type so that float is the same as double. Some systems might even have 16- or 32-bit char, which makes sizeof (float) equal 2 or 1. Using...
  8. Also, the array access in code like this: ...

    Also, the array access in code like this:



    (*(file_array + index)).Matricola


    is more usually written like this:
  9. Replies
    35
    Views
    2,195

    Do you already have a backup of all files? If...

    Do you already have a backup of all files? If not, what will you verify them against?

    Most backup software will do some sort of file verification automatically and will let you roll back to any...
  10. Replies
    35
    Views
    2,195

    For checksumming a large number of files, I'd use...

    For checksumming a large number of files, I'd use existing tools. You can do this easily in Linux, but it should work under WSL just as well:



    find DIR -type f -print0 | xargs -0 -n1 -P8...
  11. Replies
    15
    Views
    959

    What do you mean by "mounted media"? Every part...

    What do you mean by "mounted media"? Every part of the file system (even the root directory) is on mounted media (except for special system directories like /proc and /sys which exist without media...
  12. Replies
    6
    Views
    774

    Unless, of course, stdout is fully buffered...

    Unless, of course, stdout is fully buffered (e.g., it doesn't point at an interactive device like a terminal).
  13. Replies
    5
    Views
    665

    Using strlen() to find the end of a string before...

    Using strlen() to find the end of a string before comparing the strings from the end is going to take just about as long as comparing two strings with strcmp().

    Also, your (Structure's) revstrcmp...
  14. Replies
    7
    Views
    1,072

    Reading through your threads reminds me of a...

    Reading through your threads reminds me of a project that I found where a 6502 chess program was converted to C by using 6502 emulation macros. From what I understand, the 6502 is somewhat similar to...
  15. The locking concept you are looking for is called...

    The locking concept you are looking for is called a readers-writer lock, which allows for either any number of readers or a single writer, but not both simultaneously. That's basically what...
  16. Replies
    18
    Views
    2,182

    No, because that would remove some of the...

    No, because that would remove some of the protections (e.g., type safety) that C++ provides over C. C lets you get away with more implicit type conversions than C++, and that would hamper C++'s...
  17. Replies
    2
    Views
    494

    Any macro starting with an underscore is reserved...

    Any macro starting with an underscore is reserved for the implementation, which is what defines _U_ here.

    As for why the implementation uses _U_ instead of U, imagine what would happen if an...
  18. Replies
    11
    Views
    974

    That comment looks like a copy-paste of (some...

    That comment looks like a copy-paste of (some parts of) The difference between forking and cloning a repository.
  19. Thread: Realloc limit

    by christop
    Replies
    14
    Views
    1,600

    The only systems I'm aware of are 3BSD, PalmOS,...

    The only systems I'm aware of are 3BSD, PalmOS, and Novell NetWare. Considering how old and/or esoteric these systems are (3BSD was released in 1980 (10 years before C was standardized), PalmOS was...
  20. Replies
    1
    Views
    684

    I'd go with the most straightforward solution as...

    I'd go with the most straightforward solution as it's not a terribly complicated operation:


    int number_of_slots_that_have_something_other_than_0xff(const unsigned char array[50])
    {
    int...
  21. This isn't the only problem, but fgetc() returns...

    This isn't the only problem, but fgetc() returns int (not char), so c also needs to be declared as int.
  22. Replies
    10
    Views
    1,602

    I'm not 100% sure, no. Is that considered a true...

    I'm not 100% sure, no. Is that considered a true VLA, though? I thought (perhaps mistakenly) that a VLA was only an automatic variable array whose size was determined at run time. A function...
  23. Replies
    10
    Views
    1,602

    C99 and later support this type of function...

    C99 and later support this type of function declaration:



    void how(int x, int y, int array[x][y]);


    Then you just have to pass in the two dimensions (x and y) of the array when you call it....
  24. Also, PINs (also IDs, SSNs, phone numbers, etc.)...

    Also, PINs (also IDs, SSNs, phone numbers, etc.) should not be treated as numbers, even though they are numeric. They should be strings. Your example gives a good reason: if the user enters something...
  25. Tail call optimization is not guaranteed by C, so...

    Tail call optimization is not guaranteed by C, so you are very likely running into a call stack limit as @jimblumberg pointed out.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4