473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

compile errors. pls help

Hi,

I am really not good at c/c++.
Some simple code..
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "simlibdefs.h"
extern int *list_rank, *list_size; /// this is the line 6
extern int maxatr, maxlist, next_event_type;
extern double *transfer, sim_time, prob_distrib[26];
extern struct master {
double *value;
struct master *pr;
struct master *sr;

} **head, **tail;
/* Declare simlib functions. */
---

when I compile this with other files, I got the error msg like this:
simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"
I am using gcc to compile files...
Thanks a lot,
Beet
Jun 27 '08 #1
9 2433
In article <df**********************************@k13g2000hse. googlegroups.com>,
beet <wh****@gmail.comwrote:

[...]
>#include "simlibdefs.h"

extern int *list_rank, *list_size; /// this is the line 6
[...]
>when I compile this with other files, I got the error msg like this:

simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"
http://www.c-faq.com/cpp/headerglom.html
dave

--
Dave Vandervies dj3vande at eskimo dot com
I'm a bad driver. I miss things.
No, no, bad drivers _hit_ things.
--Richard Gadsden and Dan Birchall in the scary devil monastery
Jun 27 '08 #2
beet wrote:
>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "simlibdefs.h"

extern int *list_rank, *list_size; /// this is the line 6
---

when I compile this with other files, I got the error msg like this:
simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"
Your problem list not in the code you posted, but in the code you did not.

Check simlibdefs.h for a missing bracket or #endif.

--
Ian Collins.
Jun 27 '08 #3
beet wrote:
>
Hi,

I am really not good at c/c++.
Some simple code..

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "simlibdefs.h"

extern int *list_rank, *list_size; /// this is the line 6
extern int maxatr, maxlist, next_event_type;
extern double *transfer, sim_time, prob_distrib[26];
extern struct master {
double *value;
struct master *pr;
struct master *sr;

} **head, **tail;

/* Declare simlib functions. */
---

when I compile this with other files, I got the error msg like this:
What do you mean "compile this with other files"?
simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"
[...]

Is this file simlib.h?

What's in simlibdefs.h? I see this often when the last-included file
isn't correct, leaving some dangling definition/declaration.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Jun 27 '08 #4
beet <wh****@gmail.comwrites:
On Apr 18, 4:26*pm, Kenneth Brody <kenbr...@spamcop.netwrote:
>beet wrote:
I am really not good at c/c++.
Some simple code..
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "simlibdefs.h"
extern int *list_rank, *list_size; * */// this is the line 6
extern int maxatr, maxlist, next_event_type;
extern double **transfer, sim_time, prob_distrib[26];
extern struct master {
* * double **value;
* * struct master *pr;
* * struct master *sr;
} **head, **tail;
/* Declare simlib functions. */
---
when I compile this with other files, I got the error msg like this:

What do you mean "compile this with other files"?
simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"
[...]
>Is this file simlib.h?

What's in simlibdefs.h? *I see this often when the last-included file
isn't correct, leaving some dangling definition/declaration.
[...]
>
Thanks for the reply, the simlibdefs.h is listed:
/* This is simlibdefs.h. */
#ifndef _simlibdefs_
#define _simlibdefs_
[...]
#endif
[...]

I see nothing wrong with your simlibdefs.h. I *see* nothing wrong
with your other source file when I view it in my newsreader. However,
a closer look at the article and its headers indicates that it's
encoded as "quoted-printable". When I saved your article as a text
file, I see several occurrences of "=A0", which is the
quoted-printable encoding for the character 0xa0 or decimal 160, which
is the "NO-BREAK SPACE" character in the ISO-8859-1 character set
specified in your article's header. When I manually removed the "=A0"
encodings, the code compiled without error.

Whatever editor you used to create your C source file probably
inserted these characters automatically for some reason. That would
be fine if you were creating a text file intended to be printed or
otherwise processed using software that understands the "NO-BREAK
SPACE" character, but it's not a valid character in C. (Note: the
fact that I saw "=A0" sequences rather than NO-BREAK SPACE control
characters is probably an artifact of the way I saved the file; either
will have about the same effect.)

Find some way to replace these characters with ordinary spaces, and
try to use an editor that's designed to work with source code.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #5
On Apr 20, 5:15*pm, Keith Thompson <ks...@mib.orgwrote:
beet <whh...@gmail.comwrites:
On Apr 18, 4:26*pm, Kenneth Brody <kenbr...@spamcop.netwrote:
beet wrote:
I am really not good at c/c++.
Some simple code..
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "simlibdefs.h"
extern int *list_rank, *list_size; * */// this is the line 6
extern int maxatr, maxlist, next_event_type;
extern double **transfer, sim_time, prob_distrib[26];
extern struct master {
* * double **value;
* * struct master *pr;
* * struct master *sr;
} **head, **tail;
/* Declare simlib functions. */
---
when I compile this with other files, I got the error msg like this:
What do you mean "compile this with other files"?
simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"
[...]
Is this file simlib.h?
What's in simlibdefs.h? *I see this often when the last-included file
isn't correct, leaving some dangling definition/declaration.
[...]
Thanks for the reply, the simlibdefs.h is listed:
/* This is simlibdefs.h. */
#ifndef _simlibdefs_
#define _simlibdefs_
[...]
#endif

[...]

I see nothing wrong with your simlibdefs.h. *I *see* nothing wrong
with your other source file when I view it in my newsreader. *However,
a closer look at the article and its headers indicates that it's
encoded as "quoted-printable". *When I saved your article as a text
file, I see several occurrences of "=A0", which is the
quoted-printable encoding for the character 0xa0 or decimal 160, which
is the "NO-BREAK SPACE" character in the ISO-8859-1 character set
specified in your article's header. *When I manually removed the "=A0"
encodings, the code compiled without error.

Whatever editor you used to create your C source file probably
inserted these characters automatically for some reason. *That would
be fine if you were creating a text file intended to be printed or
otherwise processed using software that understands the "NO-BREAK
SPACE" character, but it's not a valid character in C. *(Note: the
fact that I saw "=A0" sequences rather than NO-BREAK SPACE control
characters is probably an artifact of the way I saved the file; either
will have about the same effect.)

Find some way to replace these characters with ordinary spaces, and
try to use an editor that's designed to work with source code.

--
Keith Thompson (The_Other_Keith) <ks...@mib.org>
Nokia
"We must do something. *This is something. *Therefore, we must do this.."
* * -- Antony Jay and Jonathan Lynn, "Yes Minister"- Hide quoted text -

- Show quoted text -
Hi Keith,

Thanks for your reply. I should post more info on my code.
The simlib.c and simlib.h and simlibdefs.h themselves were good to
compile
and get an obj file. Once I tried to link simlib.o to another c++ obj
getFunc.obj; I got the above errors. All these c/c++ code was supposed
to link
some Fortran code, using f90...

so my simple makefile:

#makefile for pvar search

FF = f90
GCC = gcc -Wall -g

all: pvar

mbsubs.o: mbsubs.for
$(FF) -c mbsubs.for

pbsubs.o: pbsubs.for
$(FF) -c pbsubs.for

tvar.o: tvar.for
$(FF) -c tvar.for

tbsubs.o: tbsubs.for
$(FF) -c tbsubs.for

pvar.o: pvar.for
$(FF) -c pvar.for

simlib.o: simlib.c simlib.h simlibdefs.h
$(GCC) -c simlib.c

getFunc.o: getFunc.cpp getFunc.h
$(GCC) -c getFunc.cpp

pvar: pvar.o mbsubs.o tvar.o tbsubs.o pbsubs.o getFunc.o simlib.o
$(FF) -o pvar pvar.o mbsubs.o tvar.o tbsubs.o pbsubs.o
getFunc.o simlib.o -L/opt/gcc/3.4.4/lib/ -lc -lstdc++
----

Thanks again for your help.

Beet
Jun 27 '08 #6
Keith Thompson wrote:
[...]
I see nothing wrong with your simlibdefs.h. I *see* nothing wrong
with your other source file when I view it in my newsreader. However,
a closer look at the article and its headers indicates that it's
encoded as "quoted-printable". When I saved your article as a text
file, I see several occurrences of "=A0", which is the
quoted-printable encoding for the character 0xa0 or decimal 160, which
is the "NO-BREAK SPACE" character in the ISO-8859-1 character set
specified in your article's header. When I manually removed the "=A0"
encodings, the code compiled without error.

Whatever editor you used to create your C source file probably
inserted these characters automatically for some reason. That would
be fine if you were creating a text file intended to be printed or
otherwise processed using software that understands the "NO-BREAK
SPACE" character, but it's not a valid character in C. (Note: the
fact that I saw "=A0" sequences rather than NO-BREAK SPACE control
characters is probably an artifact of the way I saved the file; either
will have about the same effect.)
[...]

It may not be his text editor, but rather his newsreader. Note that
my post contains no such "hidden" characters, yet the quoted parts
of my post in his reply have replaced some spaces with "=A0"s.

Which brings us back to what the actual problem may be. I would
recommend, if possible, looking at the output of the preprocessor,
and looking backwards from the line giving the error to see what is
the "real" error.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Jun 27 '08 #7
beet <wh****@gmail.comwrites:
On Apr 20, 5:15Â*pm, Keith Thompson <ks...@mib.orgwrote:
>beet <whh...@gmail.comwrites:
<snip>
>beet wrote:
<snip>
when I compile this with other files, I got the error msg like this:
<snip>
simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"
<snip>
>... Â*However,
a closer look at the article and its headers indicates that it's
encoded as "quoted-printable". Â*When I saved your article as a text
file, I see several occurrences of "=A0",
<snip>
>--
Keith Thompson (The_Other_Keith) <ks...@mib.org>
Please don't quote sig blocks.

<snip>
The simlib.c and simlib.h and simlibdefs.h themselves were good to
compile
and get an obj file. Once I tried to link simlib.o to another c++ obj
getFunc.obj; I got the above errors.
Sounds very unlikely. The "above errors" are compile-time errors,
not link errors. If the errors originally shown are indeed still
occurring (and Keith Thompson's diagnosis of the problem was no the
issue) you need to post the actual code.

--
Ben.
Jun 27 '08 #8
beet <wh****@gmail.comwrites:
[...]
>beet wrote:
[...]
simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"
[...]
Hi Keith,

Thanks for your reply. I should post more info on my code.
The simlib.c and simlib.h and simlibdefs.h themselves were good to
compile
and get an obj file. Once I tried to link simlib.o to another c++ obj
getFunc.obj; I got the above errors. All these c/c++ code was supposed
to link
some Fortran code, using f90...

so my simple makefile:

#makefile for pvar search

FF = f90
GCC = gcc -Wall -g
[snip]

When you post a followup, it's rarely necessary to quote the entire
article to which you're replying. Quote only what's necessary for
your followup to make sense to someone who hasn't seen the original
article. In particular, don't quote signatures (the stuff at the
bottom introduced by the "-- " delimiter) unless you're actually
commenting on them.

You mention a "getFunc.obj" file, but all the object files mentioned
in your Makefile have a ".o" suffix, not ".obj".

You talk about C++, but the source you've shown us is C (yes, C and
C++ are two different languages), and you're invoking gcc in a way
that causes it to act as a C commpiler.

You say that you got "the above" errors when trying to link, but the
errors you reported were:

simlib.h:6: error: expected init-declarator before "extern"
simlib.h:6: error: expected `,' or `;' before "extern"

Those are compile-time errors, not linker errors.

We can't help with C++, Fortran, or Makefiles. There are other
newsgroups for those topics: comp.lang.c++, comp.lang.fortran, and a
newsgroup that deals with programming on whatever system you're using,
perhaps comp.unix.programmer.

If you're still having trouble with C, as the error messages indicate,
try narrowing down the problem. Make a copy of your source files and
start deleting stuff. Trim it down the point where it's as short as
possible while still exhibiting the error. Try manually inserting the
contents of an include file, replacing the "#include" directive. It's
likely that this will help you detect the error yourself; if not, feel
free to post your code an error messages here.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #9
beet wrote:
>
.... snip ...
>
The simlib.c and simlib.h and simlibdefs.h themselves were good
to compile and get an obj file. Once I tried to link simlib.o to
another c++ obj getFunc.obj; I got the above errors. All these
c/c++ code was supposed to link some Fortran code, using f90...
C++ is NOT C. That is a different language, and mixing output code
without special care (only with a C++ compiler) is not generally
possible. I don't think you are ready for the reasons, so just
don't try to do it.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: banjo123 | last post by:
Dear java.help: I just started learning java and was trying to compile some java sourc from the Javascript World Submission webpage. I know I have loaded m JDK successfully since I can compile...
1
by: Ravi Chaudhary | last post by:
Hi, We are using VS.Net 2003 and coding in VB.net. The solution has 38 projects; most of the projects in the solution reference other projects (without any circular references) and all the...
3
by: arthur-e | last post by:
A new Machine was set up by our IS department - it came with Office Pro 2003. Access97, Word97 and Excel 97 were added. I'm trying to update an Access 97database to 2003 but get weird compiling...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
1
by: Ray Wampler | last post by:
According to the information on the Microsoft web site, code written in VB.NET 2002 can simply be recompiled using VS.NET 2003. However, I have found that code which compiles cleanly in VS.Net...
3
by: Daren Fox | last post by:
I am writing an application that will require new commands to be added while the program is still running. I thought I had found the answer in .nets compiler facilities. I would seperate my...
1
by: Ravi Chaudhary | last post by:
Hi, We are using VS.Net 2003 and coding in VB.net. The solution has 38 projects; most of the projects in the solution reference other projects (without any circular references) and all the...
2
by: Andrus | last post by:
I need compile in-memory assembly which references to other in-memory assembly. Compiling second assembly fails with error Line: 0 - Metadata file 'eed7li9m, Version=0.0.0.0, Culture=neutral,...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.