|
From: Steve B. <iac...@no...> - 2003-01-07 18:56:50
|
Hi there, this is my first post, so please forgive me if my message is
out of context for this list.
I am building an application in c++ on freebsd, and can't get 2 .c files
to merge properly. When I compile, I get 'undefined CServer' when I
compile. I tried defining the 'server' variable with extern, but I don't
know if I was using extern in the proper context. For instance, here are
snippets of the 2 files:
-----snip server.cc--------
#include "myheader.h"
class CServer {
int var1;
int var2;
string var3;
string var4;
void addServer(int, string, string);
}
void CServer::addServer(int a, string b, string c) {
var3 = c;
var4 = b;
var3 = a;
}
--------end snip server.c-----------
------snip main.cc-----------
void main() {
CServer *server; // The problem is here.
server = new CServer;
server.addServer(feedvar, feedvar, feedvar);
/* Do some other stuff */
----------end snip main.cc---------
Another problem: In this same program, I would like main.cc to connect
to a mysql database early in main(), then allow the server.cc file (more
specifically, the member functions of CServer) to read/write to the db.
I know the mysql syntax is correct, as when I put all of the code in
one file, everything works ok. Is this another extern problem? What
part of the mysql code to I have to initialize with extern and where?
Example:
main.c------
// all of the mysql db stuff defined and included in 'myheader.h'
#include "myheader.h"
main() {
Connection db_connection;
db_connection.connect(//send db info here)
end snip main.c----------
Eventually, the server.c file opens up a table, then does it's thing,
but when compiling, it seems as though the database connection doesn't
even exist (from the point of view of server.c).
What is the easiest way to link these 2 files so they merge and appear
as one? Or is that the purpose of extern? I simply want to divide up
my code so I can have 'modules' written in each .c file to make it
easier to maintain.
Thanks for any help in advance.
Steve Bertrand
|
|
From: Wobien <wo...@pl...> - 2003-01-07 22:46:42
|
----- Original Message -----
From: "Steve Bertrand" <iac...@no...>
To: <dev...@li...>
Sent: Tuesday, January 07, 2003 7:55 PM
Subject: [Dev-C++] using 2 .c files
> Hi there, this is my first post, so please forgive me if my message is
> out of context for this list.
>
> I am building an application in c++ on freebsd, and can't get 2 .c files
> to merge properly. When I compile, I get 'undefined CServer' when I
> compile. I tried defining the 'server' variable with extern, but I don't
> know if I was using extern in the proper context. For instance, here are
> snippets of the 2 files:
>
Each file you make must have the definitions of all the objects you use in
it.
Your file main.cc uses the class CServer, but it does not have a definition
of it.
You can put the declaration of class CServer in a header file and include
that header file in server.cc and in main.cc
> -----snip server.cc--------
>
> #include "myheader.h"
>
> class CServer {
> int var1;
> int var2;
> string var3;
> string var4;
>
> void addServer(int, string, string);
> }
>
> void CServer::addServer(int a, string b, string c) {
>
> var3 = c;
> var4 = b;
> var3 = a;
> }
>
> --------end snip server.c-----------
>
> ------snip main.cc-----------
>
> void main() {
>
> CServer *server; // The problem is here.
> server = new CServer;
>
> server.addServer(feedvar, feedvar, feedvar);
>
> /* Do some other stuff */
>
> ----------end snip main.cc---------
>
I do´nt understand exactly what your second problem is, but I think it might
be that
server.cc does not have the object db_connection you define in main.cc
You can try to add in server.cc:
extern Connection db_connection;
before you work with the connection.
Wobien
> Another problem: In this same program, I would like main.cc to connect
> to a mysql database early in main(), then allow the server.cc file (more
> specifically, the member functions of CServer) to read/write to the db.
> I know the mysql syntax is correct, as when I put all of the code in
> one file, everything works ok. Is this another extern problem? What
> part of the mysql code to I have to initialize with extern and where?
> Example:
>
> main.c------
>
> // all of the mysql db stuff defined and included in 'myheader.h'
> #include "myheader.h"
>
> main() {
>
> Connection db_connection;
> db_connection.connect(//send db info here)
>
> end snip main.c----------
>
> Eventually, the server.c file opens up a table, then does it's thing,
> but when compiling, it seems as though the database connection doesn't
> even exist (from the point of view of server.c).
>
> What is the easiest way to link these 2 files so they merge and appear
> as one? Or is that the purpose of extern? I simply want to divide up
> my code so I can have 'modules' written in each .c file to make it
> easier to maintain.
>
> Thanks for any help in advance.
>
> Steve Bertrand
>
>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: <che...@te...> - 2003-01-08 19:30:59
|
Hello: this is my first post. I was using Visual C++ but I thought to try a GPL IDE. So, I downloaded the Dev-C++ 4.9.7.1 ( 5.0 beta ). It's very good and like it but I miss a debugger that run like in a comme= rcial IDE, ie , with watches , run the program step by step , etc in VISUAL WAY. why is the reason? I have seen that http://www.bloodshed.net/ says that don't use Insight in 5.0 release. must I wait the final release ? what I can do? Thanks !!!!!!!!! |
|
From: Esteban V. <est...@ho...> - 2003-01-09 18:58:08
|
Lamento no poder ayudarte, a mi me pasó lo mismo y no se pude resolverlo. En general trato de correr el mismo programa en linux y ahí no tengo problemas con el debugger. Parece ser que la version del gdb para windows no funciona bien y la version del gdb para linux funciona sin problemas. saludos, Esteban... PD: Espero que los de habla inglesa no se quejen por nuestro español... ----- Original Message ----- From: "Jose María Zaragoza" <che...@te...> To: "Esteban Valverde" <est...@ho...> Sent: Thursday, 09 January, 2003 15:28 Subject: Re[2]: [Dev-C++] I can't debug in Dev-C++ 4.9.7.1 Hola gracias por responder. Instalé la versión de 12 MB. Yo me refiero a que cuando pongo un punto de ruptura y doy a depurar , las opciones de Siguiente paso o Avanzar Paso a Paso no me funcionan. Tampoco me funciona ver el valor de las variables definidas en los "watches". Se que incluye el debugger gdb ( al menos el ejecutable viene ) , pero no se usarlo y me gustaría que la parte visual funcionase ... Lo que no se si es porque es una beta o es que no se usarlo. Muchas gracias por todo Saludos EV> Hola, cuando instalates el devcpp, debería ser la version completa (más o EV> menos 12MBytes) que incluye el debbuger (gdb). Si instalastes sólo el ide EV> (mas o menos 2Mbytes) no vas a tener el debugger. De todos modos, con EV> debugger y todo muchas veces que intenté utilizarlo se me cuenga la EV> máquina.... EV> saludos, Esteban -- Saludos |
|
From: Esteban V. <est...@ho...> - 2003-01-09 19:07:11
|
Hi, here is the english version of the message with others comments... IŽm sorry canŽt help you, IŽve the same problem with the debugger. gdb run without problems in linux but doesnŽt run without bugs in windows. May be, the windows version of gbd insŽt the same for linux. In my case to debugg console programs I try to write them in ansi and test them in linux (because de debugger) and them run them in dos. best regards, Esteban... PD: IŽm sorry for the non-spanish speaking people.... |