Search:

Type: Posts; User: Sir Galahad

Page 1 of 10 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    37
    Views
    691

    See this...

    See this. Now just translate that to C...
  2. Replies
    3
    Views
    363

    Incidentally, you can detect endianness very...

    Incidentally, you can detect endianness very easily at runtime.



    #include <stdbool.h>
    #include <stdint.h>
    #include <stdlib.h>

    bool little_endian(void) {
    static bool state = false;
  3. This has apparently been an issue for quite some...

    This has apparently been an issue for quite some time now. See this.
  4. Replies
    35
    Views
    1,400

    You'd still need some sort of tag-management...

    You'd still need some sort of tag-management system on top of that. I'm sure they exist. (Search Github?)
  5. Replies
    35
    Views
    1,400

    Well that is true, and in fact there are other...

    Well that is true, and in fact there are other file formats as well that could be considered as containing "metadata" that Windows may be able to present to the user. In the case of "generic" binary...
  6. Replies
    35
    Views
    1,400

    What you're talking about doesn't seem to be...

    What you're talking about doesn't seem to be applicable to regular files. Image files carry metadata that can be extracted, which is what Windows is doing there.

    That said, there may be other ways...
  7. Replies
    35
    Views
    1,400

    I honestly don't understand the warning. I'm...

    I honestly don't understand the warning. I'm tempted to blame the WIN32 stat.h implementation (M$ loves to break API's).
  8. Replies
    35
    Views
    1,400

    Ah, thanks! It looks like dirent.h may not be...

    Ah, thanks! It looks like dirent.h may not be available on all Windows machines by default either, so a drop-in header may still be required (this one looks like a pretty good implementation).
    ...
  9. Replies
    35
    Views
    1,400

    Just out of curiosity, I wonder if this compiles...

    Just out of curiosity, I wonder if this compiles and runs ok on Windows?



    #ifdef __linux__
    #include <dirent.h>
    #include <sys/stat.h>
    #include <unistd.h>
    #elif _WIN32
    #include <dir.h>
  10. Thanks! You're right though, I should just embed...

    Thanks! You're right though, I should just embed it at the lowest level. But I probably will make it opt-in rather than opt-out. That way, the user can decide for themselves which way to go. Most...
  11. Thoughts on adding safety checks to a library

    I've been working on an array library and now I'm thinking of adding built-in protections for things like out-of-bounds array accesses and such. Currently there are some sanity checks in place but it...
  12. Thread: FIFO Queue

    by Sir Galahad
    Replies
    21
    Views
    1,151

    Consider the state of this object: struct...

    Consider the state of this object:



    struct Queue q;


    The object's members are most likely "pointing" to invalid memory addresses. The queueInit function is simply defined to ensure that the...
  13. No, divide and conquer implies recursion. This...

    No, divide and conquer implies recursion. This would be the "iterative approach".
  14. The common prefix length can be computed pretty...

    The common prefix length can be computed pretty efficiently without all of those expensive allocations.



    #include "stdlib.h"

    size_t common_prefix_s(const char* s1, const char* s2)
    {
    ...
  15. Replies
    18
    Views
    1,805

    LOL. Yeah I just realized that while I was on my...

    LOL. Yeah I just realized that while I was on my bike ride. Meh...
  16. Replies
    18
    Views
    1,805

    Well I stand corrected! On a side note,...

    Well I stand corrected!

    On a side note, wouldn't it be nice if Stroustrup had made C++ completely backward-compatible with C? Just seems like it would have made things easier in the long run...
  17. Replies
    18
    Views
    1,805

    Well there was nothing wrong with that code and...

    Well there was nothing wrong with that code and certainly no good reason to raise an issue about it. Remember, languages are just tools...
  18. Replies
    18
    Views
    1,805

    Nevertheless most C constructs CAN be safely used...

    Nevertheless most C constructs CAN be safely used in C++ programs. As long as it compiles and doesn't introduce problematic side-effects, why not?
  19. Replies
    18
    Views
    1,805

    Wasn't the code that aghast posted valid C++?

    Wasn't the code that aghast posted valid C++?
  20. Good advice!

    Good advice!
  21. Replies
    15
    Views
    1,213

    So a very talented mathematician showed me how...

    So a very talented mathematician showed me how this can actually be done.

    The main idea is to repeatedly apply a calculation in such a way that it causes an "overflow" in a given fixed-precision...
  22. Replies
    15
    Views
    1,213

    Or maybe this? Repeatedly subdivide into 256...

    Or maybe this? Repeatedly subdivide into 256 "spaces" (in single byte chunks) until enough "bits of the mantissa" have been processed?



    #include "float.h"
    #include "limits.h"

    /*
    Generate...
  23. Replies
    15
    Views
    1,213

    Thanks for all the useful suggestions everyone! I...

    Thanks for all the useful suggestions everyone! I do wonder if the mantissa bits could somehow be "detected" (computed) without any prior assumptions? If so then these methods could be used as a...
  24. Replies
    15
    Views
    1,213

    I wouldn't use rand() for anything other than a...

    I wouldn't use rand() for anything other than a toy program, I was just giving an example of the interface I was thinking of.

    The platform independant part I was referring to was how the numbers...
  25. Replies
    15
    Views
    1,213

    Nice! One issue with that though is being...

    Nice! One issue with that though is being somewhat limited by the RAND_MAX term. Maybe constructing the number from a string of bits to fill the largest integral machine type would be better?

    I...
Results 1 to 25 of 248
Page 1 of 10 1 2 3 4