473,670 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2451
In article <df************ *************** *******@k13g200 0hse.googlegrou ps.com>,
beet <wh****@gmail.c omwrote:

[...]
>#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.c omwrites:
On Apr 18, 4:26*pm, Kenneth Brody <kenbr...@spamc op.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_Keit h) <ks***@mib.or g>
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.orgw rote:
beet <whh...@gmail.c omwrites:
On Apr 18, 4:26*pm, Kenneth Brody <kenbr...@spamc op.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_Keit h) <ks...@mib.or g>
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.c omwrites:
On Apr 20, 5:15Â*pm, Keith Thompson <ks...@mib.orgw rote:
>beet <whh...@gmail.c omwrites:
<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_Keit h) <ks...@mib.or g>
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.c omwrites:
[...]
>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.ob j" 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.fortr an, and a
newsgroup that deals with programming on whatever system you're using,
perhaps comp.unix.progr ammer.

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_Keit h) <ks***@mib.or g>
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
2248
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 other examples but when I try t compile the following code, I get several errors. I typed "javac J1.java(source file name)" Any feedback is appreciated.
1
1608
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 references were added to using the Projects tab on the Add Reference dialog and not by browsing to the DLL for the project. When we build or run the solution "bogus" compile errors
3
1857
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 errors - Date, Format and Left give errors. I've registered the missing (or those ocx's) that were indicated as missing- iincluding - mscomct2.ocx - and the date picker showed up but
2
5732
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 in debug mode, the following errors happened: d:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xdebug(29): error C2365: 'new' : redefinition; previous definition was a 'member function' d:\Program Files\Microsoft Visual Studio...
1
1449
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 2002 gets new compile errors in VS 2003. It appears that there are new scope rules in VB.NET 2003. I get "Name not declared" errors on public functions in public modules. The errors are fixed by wrapping the module in a name space and then...
3
6237
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 commands out into a dll and compile this at startup and when the source file is changed. This works fine on startup of the application. But when I try to recompile the dll during runtime it doesnt seem to work. If I leave the current dll in place then it...
1
2065
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 references were added to using the Projects tab on the Add Reference dialog and not by browsing to the DLL for the project. When we build or run the solution "bogus" compile errors
2
6919
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, PublicKeyToken=null' could not be found Saving assembly to Windows temp directory for referencing only creates huge amout of temporary
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6216
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4213
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1795
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.