Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Question about a splint diagnostic

Reply
Thread Tools

Question about a splint diagnostic

 
 
Richard Heathfield
Guest
Posts: n/a
 
      07-30-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) said:

<snip>
>
> By the way why is advice on how to handle large projects in C
> out of topic ?


The C part of it isn't, but the C part is not difficult, and does not lend
itself to particularly involved discussions. In fact, it can be described
in about three words - "do it properly".

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      07-30-2006
(E-Mail Removed) writes:
> Keith Thompson wrote:
>> The documentation for splint would likely be instructive.
>>
>> As a matter of program design, having the same typedef (assuming it's
>> intended to be the same) in two separate source files is a bad idea,
>> even if it's legal. Put it in a header file included by both .c
>> files, with include guards so the compiler sees the typedef only once
>> per translation unit.
>>
>> <OT>
>> For a large project, you should probably use some system that figures
>> out how to invoke the compiler for you, such as a Makefile or an IDE.
>> This would probably invoke the compiler once for each .c file; you
>> should probably invokes splint the same way, possibly under control of
>> your Makefile.
>> </OT>

>
> out_of_topic {
> I just did a quick experiment with splint. I used it
> on a source file without main and it didn't produce
> any sort of "object" file so I think that in order to
> detect various discrepancies between different source
> files it needs to be invoked with all the files together.


Of course it didn't produce an object file. It's a static source code
checker; that's not its job. If by "object" file you meant something
that splint can use to do checking across translation units, that's a
good point; if splint doesn't do that, either it can't do cross-unit
checks or it uses some other method to do them. You'll undoubtedly
find that information in the splint manual.

Quite possibly it's going to warn about things that are perfectly
legal. In your original example, you had the same typedef in two
different translation units. This is quite legal, but it could be a
maintenance headache; if you change it, you'll have to make sure it
remains consistent across all the multiple definitions. Perhaps this
is what splint is warning you about. As we've mentioned, writing the
typedef exactly once in a header is a much better approach.

> I do need to read the manual eventually.


Yep.

> }
>
> By the way why is advice on how to handle large projects in C
> out of topic ?


Because the C standard doesn't provide a way to do it. Even how a
compiler is invoked is outside the scope of the language; different
compilers are invoked in different ways. Makefiles, for example, are
one way to manage large projects -- and there are a number of tools
built on top of that, tools that generate Makefiles from some even
higher-level description. All these tools are system-specific.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
 
Herbert Rosenau
Guest
Posts: n/a
 
      07-31-2006
On Sun, 30 Jul 2006 20:34:12 UTC, (E-Mail Removed) wrote:

>
> out_of_topic {
> I just did a quick experiment with splint. I used it
> on a source file without main and it didn't produce
> any sort of "object" file so I think that in order to
> detect various discrepancies between different source
> files it needs to be invoked with all the files together.


It is NOT the job of splint to produce object files. Its job is "only"
to check the source for errors and complain against them.

> I do need to read the manual eventually.
> }



> By the way why is advice on how to handle large projects in C
> out of topic ?


There is no standard defined
- how to invoke a compiler
- how to invoke a linker
- how to invoke another tools (like make)
- how to get multiple source files bounded to an executeable

As this group is only to handle C in a compatible way you has to ask
in a group relevant to your OS, your specific compiler, your specific
linker, your specific tool you use to come from different sources to a
single executeable. The ways to get it are so incomatible and
different that there is simple no common possibility.

The standard describes exactly how to write C in an compatible way
each and any compiler has to translate fine - but how to get from the
output a compiler produces when it has to compile multiple translation
units to get them bouned to a single executeable are at least system
specific or a bit harder specific to a specific compiler.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is splint really better than lint? Is there a better tool than splint? Peter Bencsik C Programming 2 09-21-2006 10:02 PM
How to use splint on the win32 platform? arcliber@gmail.com C Programming 1 07-07-2006 04:10 PM
Ignore include header files with Splint Henry Fr?d?ric C Programming 8 03-29-2005 07:05 PM
"Implicitly only" splint warnings Guy Eschemann C Programming 2 01-13-2005 08:25 AM
Using splint on C files under MS VC6 Greg Roberts C Programming 0 01-23-2004 12:08 PM



Advertisments