Search:

Type: Posts; User: synthetix

Page 1 of 5 1 2 3 4

Search: Search took 0.01 seconds.

  1. This worked, but only after I put parenthesis...

    This worked, but only after I put parenthesis around the conditional, like this:



    /* A-ok on gcc 4.8 */
    const unsigned long s = (long)(clk.tv_sec - recstart.tv_sec) - ((clk.tv_nsec <...
  2. Thanks! This what what I ended up using: ...

    Thanks! This what what I ended up using:


    struct timespec clk,recstart;
    unsigned long min,sec;

    if(current_frame==0)
    recstart=clk;

    sec = (((clk.tv_sec-recstart.tv_sec)*1000) +...
  3. Thanks, Salem. The problem is the tv_nsec member...

    Thanks, Salem. The problem is the tv_nsec member of timespec resets to 0 every second. So if I try to subtract 'start' from 'now,' I eventually get a negative value. I could multiply now by tv_sec,...
  4. How to display incrementing second counter using system timer?

    I have an app that records frames from a camera and displays a min/sec counter to the user when record is pressed so they know how long the recording has been going. I need this counter to be...
  5. Replies
    13
    Views
    2,334

    That would be fine except the file reader...

    That would be fine except the file reader presents these values as integers, and that's the only way I have access to them.
  6. Replies
    13
    Views
    2,334

    This works: uint8_t input = 47; uint8_t...

    This works:


    uint8_t input = 47;
    uint8_t temp = (((input%100)/10)*16)+(input%10);
    //result is 71

    However, I'd like to avoid the division if possible. Can you see a way to do this through...
  7. Replies
    13
    Views
    2,334

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

    Sorry, I should have been more clear. Basically, I need to take a non-negative decimal value and convert it like this:


    input decimal value: 10
    output hex value: 0x10 (decimal value: 16)
    ...
  8. Replies
    13
    Views
    2,334

    Need to convert base 10 integer to base 16

    I need to convert an integer, for example 10, to its base 16 equivalent, 16. I found this code that converts a base 16 number to base 10, but I need the opposite. Plus, this code doesn't seem to work...
  9. Replies
    15
    Views
    8,719

    I'm using GCC 4.8.1 (on a Mac). However, I just...

    I'm using GCC 4.8.1 (on a Mac). However, I just tried compiling your program on an Ubuntu machine running GCC 4.7.2, and I don't get a warning unless I turn on strict aliasing (-fstrict-aliasing)....
  10. Replies
    15
    Views
    8,719

    Cast byte array to 64bt int or use a union?

    I have a byte array in my code that I need to interpret as a 64 bit integer:


    uint8_t stuff[8];

    I can cast this to a 64 bit integer like this:


    int64_t bigint = *((int64_t*)stuff)
  11. I know, that's why I thought it might be good to...

    I know, that's why I thought it might be good to ask. I guess this isn't a problem if declaring i at the top of the function (which, I think, you're supposed to to in ANSI C), but if you have a few...
  12. Yes, my mistake. :cool: Thanks.

    Yes, my mistake. :cool: Thanks.
  13. Additional scope used with for loop/initializer variable when not using C99?

    You can do this in C99:


    for(int i=0;i<100;i++){

    }

    But what if I'm not writing C99 code and want to keep the same behavior? Couldn't I just do this:
  14. Actually yes, it does. Sorry, that was a bad...

    Actually yes, it does. Sorry, that was a bad example. The example I should have used was in fact a struct:


    struct test{
    char a[5];
    char b[5];
    } test;

    memcpy(&test, &((struct...
  15. Any problem with casting like this: (char[]){0,1,2,3,4)?

    I was getting "excess elements in scalar initializer" errors from GCC from the following code, even though it still compiled and ran fine:


    void *array[] = {
    (char){0,1,2,3,4},...
  16. Thanks. I guess I'll just pass the size along...

    Thanks. I guess I'll just pass the size along with the array for now. I was trying to cut down on the number of parameters passed to function, but this will work for now!
  17. Need to determine sizeof(integer_array), but from within a function

    I need to figure out how many bytes are in an array created like this:


    int my_array[8];

    if I do this, it works as expected:


    size_t size = sizeof(my_array); //size is "32"
  18. Do I need a mutex if I'm only sharing an int between threads?

    I have a multithreaded app with a thread that needs to access an int in the main thread that provides status information (e.g. playing or paused). This int may be set and read by either thread. Do I...
  19. Is the memory for a function's local variables always freed once the function exits?

    Let's say I have a function that sets a number of local variables like this:


    void test_func(){

    long a = 1; //4 bytes
    long b = 2; //4 bytes
    long c = 3; //4 bytes
    long d = 4; //4 bytes
  20. Thanks. That's a valid point and I certainly...

    Thanks. That's a valid point and I certainly agree.



    Ah. Good call. I will definitely do that.



    Actually, the code I posted was wrong. That line should have used strlen() instead of...
  21. Well, the question wasn't really about which way...

    Well, the question wasn't really about which way is "better" or not. I'm more concerned about whether there will be any problems doing it the other way, that is using a generic void*.

    Why do you...
  22. Okay to use sizeof(void*) when allocating a new pointer to a string?

    I have a pointer-pointer variable that contains strings of characters. It is dynamically added to when more data becomes available. I must first allocate the pointer to each string, and then allocate...
  23. I figured out the problem. I was adding the...

    I figured out the problem. I was adding the direction_move vector to the camera position incorrectly. I was adding to separate X,Y,Z vector elements based on key input, where I should have been...
  24. How to combine rot/translation with first person OpenGL camera?

    I have a camera in my Open GL ES 2.0 app. Using translation/rotation matrices, I can move and rotate the scene using the WSAD keys for movement/strafe and the arrow keys for rotation. I do this by...
  25. Thanks. That pretty much answers my question! ...

    Thanks. That pretty much answers my question!


    I was cross compiling, and had to use -nostdlib to prevent linking to the build system's libc (had to point the linker to the target libc manually).
Results 1 to 25 of 102
Page 1 of 5 1 2 3 4