Search:

Type: Posts; User: Absurd

Page 1 of 10 1 2 3 4

Search: Search took 0.01 seconds.

  1. sizeof on string literal defined in #define VS char*

    Consider the following:


    #define STR "some long string"

    int main(int argc, char* argv[]) {
    char c* = "some long string";
    printf("%d\n", sizeof(c))
    printf("%d\n", sizeof(STR));...
  2. Replies
    2
    Views
    3,117

    Thanks. I'll give it a try.

    Thanks.
    I'll give it a try.
  3. Replies
    2
    Views
    3,117

    Bug in the pciutils library?

    *I just wrote a long post, hit Submit New Thread and my post somehow vanished :mad:(doesn't appear anywhere)*
    Anyway, I was playing around with the pciutils library (see my previous thread here) and...
  4. Replies
    13
    Views
    13,188

    You are a genius! $ gcc my_example.c...

    You are a genius!

    $ gcc my_example.c -L/usr/local/lib -Iproject/pciutils/lib/ -lpci -lz -ludev
    $ ./a.out
    flag
    vendor id=ec10
    vendor id=8c16
    vendor id=8680
    vendor id=8680
    vendor id=8680
  5. Replies
    13
    Views
    13,188

    When I directed the linker to /usr/local/lib, it...

    When I directed the linker to /usr/local/lib, it threw another thousand linking errors for some reason...


    $ gcc my_example.c -L/usr/local/lib -Iproject/pciutils/lib/ -lpci...
  6. Replies
    13
    Views
    13,188

    The header file that is used when I do: $ gcc...

    The header file that is used when I do:

    $ gcc -M my_example.c -Iproject/pciutils/lib/ -lpci
    is project/pciutils/lib/pci.h, (meaning the one in project/pciutils/lib/), but that's just because I...
  7. Replies
    13
    Views
    13,188

    Thanks for your help guys. This is going to be...

    Thanks for your help guys.
    This is going to be long, but please bare with me. This is very important for me, and is actually just a small part of a greater project I have already written (in...
  8. Replies
    13
    Views
    13,188

    Hey Salem. Thanks for the help. I ran the top...

    Hey Salem. Thanks for the help.
    I ran the top level makefile, and it looks like it creates some object files into pciutils/lib/, plus the pci.h is also at pciutils/lib.
    So I ran the above example...
  9. Replies
    13
    Views
    13,188

    How to use the pciutils headers and objects?

    Hey.
    I git cloned the pciutils repository (see here), and now I want to write my own version of lspci.
    What do I need to do in order for this wonderful library to be available for me?
    Note: I am...
  10. Replies
    22
    Views
    2,391

    Your approach is good in general, though there...

    Your approach is good in general, though there are still couple of problems that I could find:
    1. You say you're gonna "break if there is equality and if not to save this number in a new array and...
  11. Replies
    5
    Views
    3,177

    Because (5/9) is 0. And 0 times anything gives 0....

    Because (5/9) is 0. And 0 times anything gives 0.

    EDIT

    To be more specific: the expression you are probably looking for is: (f-32)*((float)5/9)
  12. Replies
    4
    Views
    1,241

    I thought about using structs, but that involves...

    I thought about using structs, but that involves syntax changes that would require changing an existing code.
    Isn't there a way to achieve the same results with primitives?
  13. Replies
    4
    Views
    1,241

    Can you suggest different method by which the...

    Can you suggest different method by which the above code would at least raise a warning by the compiler?
  14. Replies
    4
    Views
    1,241

    How can I enforce type safety?

    Take this code snippet as an example:


    #include<stdio.h>

    typedef unsigned foo_t;
    typedef unsigned bar_t;

    void func(foo_t foo) {
    printf("foo=%u\n", foo);
  15. Replies
    2
    Views
    461

    afaik, you can't. If "another c program" is not...

    afaik, you can't.
    If "another c program" is not part of the binary of the running process, your only option is forking new child process, and mounting another_c_program's binary to it.
  16. How to access a PCIe device's BAR from user space?

    I have a PCIe device and I read its BAR through setpci. Now suppose I want to access this address space.
    To my best understanding, this address space is a physical address space, and thus can not be...
  17. What's the __VA_ARGS__ macro and how do I use it?

    Hey.
    I'm trying to wrap my head around the idea of variadic macros, and I have several questions:

    1. Is this a C++ thing, or does is also exist in C?
    2. How do I use it?
    3. What's the...
  18. Replies
    9
    Views
    5,633

    Ohh... OK. Now it all makes sense. Thanks again!

    Ohh... OK. Now it all makes sense.
    Thanks again!
  19. Replies
    9
    Views
    5,633

    OK, I cleared the fields one at a time: int...

    OK, I cleared the fields one at a time:


    int main(int argc, char* argv[]) {

    struct pci_access* pacc;
    struct pci_dev* dev;

    pacc = pci_alloc();
    pci_init(pacc);
  20. Replies
    9
    Views
    5,633

    You're right. That's not what I was aiming for......

    You're right. That's not what I was aiming for... This should have been sizeof(struct pci_dev)...



    Yes. The only reason for doing so was to see how it works.

    Thanks!
  21. Replies
    9
    Views
    5,633

    That is actually what I was looking for. Its...

    That is actually what I was looking for. Its specification...
  22. Replies
    9
    Views
    5,633

    Sorry, I guess I should have been more clear...

    Sorry, I guess I should have been more clear about why I stuck these three lines there.

    You see, I wanted to see if omitting the flags PCI_FILL_BASES | PCI_FILL_CLASS will cause pci_fill_info()...
  23. Replies
    9
    Views
    5,633

    Help with pciutils-dev

    I am trying to familiarize myself with pciutils-dev C library, and I came across this example file.

    For simplicity, let me write (a mildly changed version of) example.c here:


    int...
  24. Replies
    4
    Views
    767

    Thanks again for teaching me some more new stuff....

    Thanks again for teaching me some more new stuff. Appreciate it.
  25. Replies
    4
    Views
    767

    Got it! Thank you. One question though: ...

    Got it! Thank you.

    One question though:



    If the output operand determines where the compiler will store the result, then how can it be an expression? Doesn't it have to be an lvalue?
Results 1 to 25 of 229
Page 1 of 10 1 2 3 4