× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Hi Frank,

The example program as it appears on the website would not compile on any C
compiler. There are multiple errors. The first error is that there is a
missing closing brace '}' in the gettoken routine. I figured this out by
looking at where the first syntax error was and working backwards. The
syntax error was on the definition of the parmdcl function that immediately
follows the gettoken routine. The definition line looked OK, so I assumed
that it must be some kind of scope problem, where the compiler is
diagnosing a procedure declaration at a point where a procedure declaration
is not valid. I looked back at the previous function (gettoken) and
counted the opening and closing braces, coming up one short on the closing
braces. I think that the closing brace should probably go immediately
after the first return statement in the gettoken routine (between lines 95
and 96 in the web listing).

This error is one of the nastiest errors for a compiler to try and explain,
since it is hard for the compiler to figure out exactly where the real
problem occurs. It just knows where it first detected an issue.

Unfortunately after I fixed this and tried the compile again I ran into
several more errors:
There is a use of the symbol "MAXTOKEN" on line 139. This symbol is not
declared anywhere in the example program. I didn't read the program
closely enough to know the intent, so I can't guess the value that it
should have.
There is a call to the "typedesc" function on line 146, but no such
function is declared in the program. There is a mention of "typedesc" in a
comment just above the declaration of the "typespec" function, so that
might be a typo.
The code calls the "bsearch" function from the C runtime, but does not
include the correct header file to get the "bsearch" prototype. An include
of "stdlib.h" should be added.
In the definition of the "compare" function on line 195 the two variables
are both named "s", which is invalid. Based on the code I would guess that
the second variable was intended to have been named "t".

I am guessing there are more problems with this code even after the
problems I mentioned are fixed. For instance, I notice that there are
several external variables declared at the top of the program. These
variables do not have definitions inside this source file, so you would
need to either add those definitions to this source code or include another
module which defines those variables.

Good luck!

Aaron Albertson





From: frank kolmann <fkolmann@xxxxxxxxx>
To: c400-l@xxxxxxxxxxxx,
Date: 01/17/2014 04:39 PM
Subject: [C400-L] C syntax errors
Sent by: c400-l-bounces@xxxxxxxxxxxx



I am new to C.

Given that C compilers throw up Syntax errors at seemingly random places,
how do experienced programmers cope?
Any advice will be most welcome.
-rant on-
To me C is the antithesis of the KISS principal. Given the convolutions
possible in C code I wonder how are any C programs written at all.
It seems that you need an ability to decompile C code in your head. The
forwards and backwards nature of deciphering a C definition is so arcane
that the only reason I can think why anyone would have designed such a
language is to show 'look at me, arnt I clever'.
C macro substitution seems to be a disaster waiting to happen. Who is
clever enough to construct a macro that can accept arbitrary input and yet
produce reliable results.
-rant off-
I fact I am trying to compile a bit of C code I found on the net that
attempts to translate C constructs into words but it fails on the iSeries
with a syntax error.
Presumable it has compiled elsewhere.
http://www.c-program-example.com/2012/02/k-r-c-programs-exercise-5-20.html

I though I was a programmer, I know Basic Fortran Cobol RPG(all variants)
but I realise now that I am just a mere dabbler and there exist super
beings with mystical abilities akin to sorcerers who program in C.

Frank Kolmann
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L)
mailing list
To post a message email: C400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.