long long and long

M

Mathieu Dutour

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
 
S

santosh

"]
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.[/QUOTE]

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.
 
M

Mohan

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
 
A

Army1987

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top