Search:

Type: Posts; User: aghast

Page 1 of 4 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    2,504

    Worth pointing this out: vpath is for finding...

    Worth pointing this out: vpath is for finding sources, not targets. You will probably be a lot more successful if you cd into $outdir, and then use vpath to refer to $sources, rather than cd'ing into...
  2. Replies
    8
    Views
    1,110

    The standard specifies that size_t is an...

    The standard specifies that size_t is an "unsigned integer type." If you declare a parameter of type size_t and try to pass a negative value as an argument in a call to the function, the compiler...
  3. Replies
    4
    Views
    589

    Exactly correct. (And a big hint about how...

    Exactly correct. (And a big hint about how everything in C works, under the hood: if the compiler knows how to allocate storage for it, you can probably get it to leave you alone. If the compiler...
  4. In C, the address-of operator creates a pointer....

    In C, the address-of operator creates a pointer. That is, if you declare


    typedef ... Foo;

    Foo foo_var;

    Foo * foo_ptr = &foo;
  5. Replies
    3
    Views
    1,130

    Your fun() decrements the num one time. But your...

    Your fun() decrements the num one time. But your code paths call fun() more than once. Let's look:

    First, you enter main. From there you start the for(init; test; update) loop. This code path...
  6. My first suggestion will be "change your...

    My first suggestion will be "change your approach!"

    If you have truly different custom implementations for all 12 possibilities, you don't really have a template, do you? Templates are cases where...
  7. A lot is going to depend on what kind of computer...

    A lot is going to depend on what kind of computer you are using. If you're on Windows, versus Linux, the way to code this will change. If you're talking about building an Arduino board to replace the...
  8. Replies
    2
    Views
    935

    You have a bunch of tests like: if...

    You have a bunch of tests like:


    if (something)
    print(message)
    if (otherthing)
    print(message)


    When more than one of the something/otherthing conditions are true,...
  9. Replies
    2
    Views
    411

    This is one of a few fairly-common idioms in...

    This is one of a few fairly-common idioms in linked-lists.

    The key here is that you don't have a "List" structure. Instead, you're using a single Node * variable to hold the pointer to the first...
  10. Replies
    4
    Views
    629

    Your code does not allocate 5 integers. Your...

    Your code does not allocate 5 integers.

    Your code says "hey, allocator, can I have space for 2 integers please?"

    Then later your code says, "hey, allocator, you know this space you gave me for...
  11. Replies
    2
    Views
    385

    Any system call will give the OS the opportunity...

    Any system call will give the OS the opportunity to force a switch. In particular, a blocking call will practically guarantee it. You might consider something like sleep(0); or a write to /dev/null. ...
  12. Thread: typedef

    by aghast
    Replies
    7
    Views
    914

    You mean, "What if you want a different type?"...

    You mean, "What if you want a different type?" :-) That would be a different typedef,
    unless you were just trying to indicate that the variable you declared was unchanging, which
    const does just...
  13. Thread: typedef

    by aghast
    Replies
    7
    Views
    914

    Typedefs have managed to become controversial,...

    Typedefs have managed to become controversial, for who-knows-what-real-reason. The Linux coding standard decries their use. They prefer that all "struct Foo" be spelled out completely. (Not sure how...
  14. Replies
    6
    Views
    663

    @op, From your question, it sounds like you...

    @op,

    From your question, it sounds like you are creating new nodes when you sort into a new order. You could solve your problem by starting with one list, removing the nodes from the list in...
  15. Replies
    3
    Views
    450

    In your header file you #include ...

    In your header file you #include <stdlib.h> outside the include-guard logic.

    This means that your header file always includes another header file, even if it gets included twice.

    In turn, this...
  16. Replies
    2
    Views
    398

    The preprocessor gets used for some truly weird...

    The preprocessor gets used for some truly weird things. In particular, it is considered "good form" when defining a macro that will be used as part of an (arithmetic) expression to wrap the contents...
  17. Replies
    17
    Views
    876

    There is no mechanism mandated by the C standard...

    There is no mechanism mandated by the C standard to work.

    However, most libraries implicitly have this information, since they want to be able to re-use the memory if you free() the allocation....
  18. Replies
    4
    Views
    583

    That doesn't look like edge detection. It looks...

    That doesn't look like edge detection. It looks like reading the image from a file.

    Why not pull that out as a separate function, put in a main(), and go from there?
  19. You need to think about where in-line assembly...

    You need to think about where in-line assembly may appear.

    For example, if it appears inside a for loop:



    for (int i = 0; i < 10; ++i) {
    __asm__("movl %eax, %edx")
    }
  20. Replies
    5
    Views
    671

    Doing it the way you suggest is probably the...

    Doing it the way you suggest is probably the "right" way to do it, in terms of producing code that can be tested and debugged.

    However, it might produce "worse" code in objective terms. Many small...
  21. The storage classes are mutually exclusive. For...

    The storage classes are mutually exclusive. For example, static means "cannot be seen from outside" (among other things), while extern means "can be seen from outside." So having something be both...
  22. It might help if you really, really learn how C...

    It might help if you really, really learn how C declarations work.

    Consider this:


    int ary[3][5];


    In C, the rule is that type operators (pointer, array, function) are read postfix,...
  23. Replies
    6
    Views
    733

    Yes, parsing C programs is slow. There are really...

    Yes, parsing C programs is slow. There are really two reasons for parsing C. One is "compilation." This is the one everybody focuses on, but that's wrong. The second reason, which occurs far more...
  24. Replies
    5
    Views
    998

    The double pointer is one solution to programmer...

    The double pointer is one solution to programmer laziness. Here's the problem:



    struct Node {
    struct Node * next;
    ...
    };

    struct Node * Head;
  25. If you're transpiling to C, the output will be C...

    If you're transpiling to C, the output will be C code, no matter how complicated or awkwardly-written.

    However, as I pointed out, there are languages with features that you just cannot effectively...
Results 1 to 25 of 94
Page 1 of 4 1 2 3 4