Showing posts with label compiler. Show all posts
Showing posts with label compiler. Show all posts

Wednesday, September 18, 2013

Tuesday, August 20, 2013

Static Library .a and Dynamic Library .so

http://www.ilkda.com/compile/Static_Versus_Dynamic.htm


Creating .so and .a in Unix
http://stackoverflow.com/questions/1648215/creating-so-and-a-in-unix

Tuesday, July 30, 2013

Difference between const & const volatile


An object marked as const volatile will not be permitted to be changed by the code (an error will be raised due to the const qualifier) - at least through that particular name/pointer.
The volatile part of the qualifier means that the compiler cannot optimize or reorder access to the object.
In an embedded system, this is typically used to access hardware registers that can be read and are updated by the hardware, but make no sense to write to (or might be an error to write to).

unsigned int const volatile *status_reg; // assume these are assigned to point to the 
unsigned char const volatile *recv_reg;  //   correct hardware addresses


#define UART_CHAR_READY 0x00000001

int get_next_char()
{
    while ((*status_reg & UART_CHAR_READY) == 0) {
        // do nothing but spin
    }

    return *recv_reg;
}
If these pointers were not marked as being volatile, a couple problems might occur:
  • the while loop test might read the status register only once, since the compiler could assume that whatever it pointed to would never change (there's nothing in the while loop test or loop itself that could change it). If you entered the function when there was no character waiting in UART hardware, you might end up in an infinite loop that never stopped even when a character was received.
  • the read of the receive register could be moved by the compiler to before the while loop - again because there's nothing in the function that indicates that *recv_reg is changed by the loop, there's no reason it can't be read before entering the loop.
The volatile qualifiers ensures that these optimizations are not performed by the compiler.

Tuesday, July 16, 2013

Error: Unterminated character constant beginning at (1)

http://gcc.gnu.org/ml/fortran/2007-12/msg00212.html

Error: Unterminated character constant beginning at (1)
aaa.f:4.72:

           print *, 'Try one of "Skip", "Test", "Verbosity" or "Cleanup"
                                                                       1
Warning: Line truncated at (1)

Fixed-form Fortran has only 72 characters per line. What happens with
longer lines is implementation dependent. However, many
programmers/programs assume that everything after column 72 is ignored
(which gfortran does).

Solution: Fix the program by splitting the line or by using the 
-ffixed-line-length-n (n is a non-negative integer).




Wednesday, February 27, 2013

Sunday, October 28, 2012