[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Problem compiling gnetman . . . .



Hi, Stuart.

Stuart Brorson wrote:
...

I checked it out, and it turns out that the problem is the UTINT
declaration in:

static char *readLine(void)
{
schLineLength = 0;
UTINT c;
[. . . . etc . . . .]

This is due to a new enhancement in gcc. The error isn't the UTINT (it's used 12 lines earlier without error). The problem is that schLineLength = 0 is a statement, not a declaration. In ANSI C 2.0, the declaration of c is illegal after any statements. In C99, this is legal, and gcc recently adopted this. It's been causing some problems at work, since some of our programmers have older compilers.

I feel strongly about making code portable, and this code currently isn't. I'll look into getting the compiler to at least print a warning about this rule, and I'll upload another version.

There's nothing about CVS that makes code read-only. In fact, the tar archive should have left everything writable, so the problems editing the file I don't understand. It's really kind of weird.

As for the include chain, you'll find that the code follows very strict rules, and has an extensive coding methodolgy behind it. One of the primary goals behind the methodology is code clarity, and I suspect you'll generally find the code easy to read. Unfortuneatly, the metholodology has never been documented in the public domain, even though DataDraw is opensource.

I don't know if you really wanted to hear the whole data dump for include chains, but here it is. Feel free to skip the rest of this message if it's not of interest.

For header files, the coding methodoloy uses the following rules:

-- The OS portability layer is the util module. Util.h includes various aspects of this, including uttypes.h. User code may directly include util.h, but not the other ut<name>.h files. Generated code also publicly includes util.h, so when including a generated header file (files of the form xxxddr.h), don't bother including util.h at all.
-- User modules generally fall into two types:
1 - databases, like the database directory. These modules put both their generated header files (dbddr.h), and user-defined header file (db.h) in the include directory. That allows all the internals to be accessed by tools using the database
2 - tools, like the schematic reader, or spice netlist writer. These modules put the generated header file (like schddr.h) in the local module directory. The module's user-defined header file (like sch.h) is also in the local directory. Tools generally have an external interface, which is a header file of the form xxxext.h, like schext.h. These external header files are put into the include directory, and are included by the tool's local header file.
-- With some exceptions, files within a module include only the module's internal header file, like sch.h. Exceptions are:
1 - Files may include standard library header files, like stdio.h
2 - Files may include other module's external header file only if they are top level control modules, such as the main loop, or the guile interface.
3 - Anything goes in the GUI. No rules apply there. Can you tell that we aren't very good at developing GUI's?
-- To help DataDraw understand externally typedefed types, files of the form xxxtypedef.h are written by hand. They only exist if the user has defined an external typedef in a given tool with the DataDraw schema editor.

The include methodology eliminates the need for the #ifdef wrappers around include files to avoid including a header file twice. It also protects a modules internals from another module.

We may want to take this discussion off the geda-user message board. My direct e-mail is bill@viasic.com.

Bill