long long and long

Discussion in 'C Programming' started by Mathieu Dutour, Jul 17, 2007.

  1. Dear all,

    I had a source code, which was doing matrix integral computation
    using "int". I had to modify it in order to use "long long".

    The problem is that "int" was used both for matrix indices
    and for matrix element. In the version I modified I want to
    use "long long" for matrix element and "int" for matrix indices.

    How to be sure that I did not forget anything. "gcc -Wall"
    accept without difficulties "long long * long" when I would like
    him to ask for an explicit cast.
    Could there exist a static source analyzer that detect such
    problems?

    Thank you in advance.

    Mathieu
    Mathieu Dutour, Jul 17, 2007
    #1
    1. Advertising

  2. Mathieu Dutour

    santosh Guest

    On Tuesday 17 Jul 2007 6:50 pm in comp.lang.c Mathieu Dutour
    <> wrote:
    Message ID: <f7ifne$1tm$>

    > Dear all,
    >
    > I had a source code, which was doing matrix integral computation
    > using "int". I had to modify it in order to use "long long".
    >
    > The problem is that "int" was used both for matrix indices
    > and for matrix element. In the version I modified I want to
    > use "long long" for matrix element and "int" for matrix indices.
    >
    > How to be sure that I did not forget anything. "gcc -Wall"
    > accept without difficulties "long long * long" when I would like
    > him to ask for an explicit cast.
    > Could there exist a static source analyzer that detect such
    > problems?
    >
    > Thank you in advance.


    Well a static source code analyser is lint. A popular version of lint is
    splint.

    But array subscripts can be any integral expression. It need not be an int
    value. Just change the objects you use for your array indexing to type int
    or unsigned, if you want. Perhaps a better type for this purpose is size_t.

    In addition to -Wall use -Wextra -pedantic and either one of -ansi
    or -std=c99, depending on whether you want conformance to C95 or partial
    conformance to C99.
    santosh, Jul 17, 2007
    #2
    1. Advertising

  3. Mathieu Dutour

    Mohan Guest

    Re: long long and long

    On Jul 17, 6:20 pm, (Mathieu Dutour) wrote:
    > Dear all,
    >
    > I had a source code, which was doing matrix integral computation
    > using "int". I had to modify it in order to use "long long".
    >
    > The problem is that "int" was used both for matrix indices
    > and for matrix element. In the version I modified I want to
    > use "long long" for matrix element and "int" for matrix indices.
    >
    > How to be sure that I did not forget anything. "gcc -Wall"
    > accept without difficulties "long long * long" when I would like
    > him to ask for an explicit cast.
    > Could there exist a static source analyzer that detect such
    > problems?


    Hope you are looking for 'lint'

    Mohan
    Mohan, Jul 18, 2007
    #3
  4. Mathieu Dutour

    Army1987 Guest

    On Tue, 17 Jul 2007 20:58:18 +0530, santosh wrote:

    > In addition to -Wall use -Wextra -pedantic and either one of -ansi
    > or -std=c99, depending on whether you want conformance to C95 or partial
    > conformance to C99.


    -ansi is for C90, for C95 use -std=iso9899:199409

    --
    Army1987 (Replace "NOSPAM" with "email")
    "Never attribute to malice that which can be adequately explained
    by stupidity." -- R. J. Hanlon (?)
    Army1987, Jul 24, 2007
    #4
  5. Mathieu Dutour

    santosh Guest

    Army1987 wrote:

    > On Tue, 17 Jul 2007 20:58:18 +0530, santosh wrote:
    >
    >> In addition to -Wall use -Wextra -pedantic and either one of -ansi
    >> or -std=c99, depending on whether you want conformance to C95 or partial
    >> conformance to C99.

    >
    > -ansi is for C90, for C95 use -std=iso9899:199409
    >


    Thanks.
    santosh, Jul 24, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    659
    Eric Sosman
    Jul 8, 2003
  2. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,178
    Peter Shaggy Haywood
    Sep 20, 2005
  3. Bart C

    Use of Long and Long Long

    Bart C, Jan 9, 2008, in forum: C Programming
    Replies:
    27
    Views:
    781
    Peter Nilsson
    Jan 15, 2008
  4. veryhotsausage
    Replies:
    1
    Views:
    1,776
    veryhotsausage
    Jul 4, 2008
  5. Oliver Graeser
    Replies:
    10
    Views:
    573
    Oliver Graeser
    Sep 26, 2008
Loading...

Share This Page