I have the following files: netfunc.h: - typedef struct{
-
char data[MAX];
-
int n;
-
}packet;
-
-
typedef struct
-
{
-
char flag_s;
-
char address;
-
unsigned char control;
-
char data[MAX];
-
unsigned char FCS1;
-
unsigned char FCS2;
-
char flag_e;
-
}frame;
-
-
typedef struct{
-
frame trama;
-
packet paquete;
-
FILE* file;
-
int tty;
-
}arguments;
-
-
-
void to_physical_layer(frame *fr, int fds);
-
void from_physical_layer(frame *fr, int fde);
-
void print_frame(frame trama);
-
void format_frame(frame *fs, packet ps,int control);
-
void format_packet(frame fs, packet *ps);
-
void to_network_layer (packet pr, FILE *pfs);
-
TX_automat_SW.h - /* ----------------------------------------------------------- *
-
* Author: Luis Sieira García <email removed>
-
* Date: May 2007
-
* No rights reserved
-
* ----------------------------------------------------------- */
-
#include <IFTI_P2_automat.h>
-
-
#define REACHED_EOF 3
-
-
-
-
/* ------------------------------------------------------------
-
* State definitions
-
* ------------------------------------------------------------ */
-
enum {
-
TX_STATE_INITIAL = AUTOMAT_INITIAL_STATE,
-
TX_STATE_READING,
-
TX_STATE_FRAMING,
-
TX_STATE_WAITING
-
};
-
-
/* ------------------------------------------------------------
-
* Event definitions
-
* ------------------------------------------------------------ */
-
enum {
-
TX_EV_OPERATIVE = 1,
-
TX_EV_READOK,
-
TX_EV_FRAMED,
-
TX_EV_TWOFRAMES,
-
TX_EV_ACK_RECEIVED,
-
};
-
-
/* ------------------------------------------------------------
-
* Action definitions
-
* ------------------------------------------------------------ */
-
TAutomat * TX_automat_SW_define( );
-
-
int read_data( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
int manage_data( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
int send_data_wait_response( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
TX_SW
Manage the automat transitions, so it includes "TX_automat_SW.h".
It needs to use some functions from netfunc.h
If I don't include netfunc.h I get
[...]
src/TX_SW.c: In function ‘main’:
src/TX_SW.c:25: error: ‘arguments’ undeclared (first use in this function)
[...]
if I include both
#include <TX_automat_SW.h>
#include <netfunc.h>
then functions are not defined in TX_automat_SW
[...]
./src/TX_automat_SW.o: In function `manage_data':
src/TX_automat_SW.c:80: referencia a `format_frame' sin definir
[...]
As I think, solution is related with #ifndef #ifdef and #endif directives, but I've never used it... and I don't know how to do it...
6 1759 RedSon 5,000
Recognized Expert Expert TX_SW
Manage the automat transitions, so it includes "TX_automat_SW.h".
It needs to use some functions from netfunc.h
If I don't include netfunc.h I get
[...]
src/TX_SW.c: In function ‘main’:
src/TX_SW.c:25: error: ‘arguments’ undeclared (first use in this function)
[...]
if I include both
#include <TX_automat_SW.h>
#include <netfunc.h>
then functions are not defined in TX_automat_SW
[...]
./src/TX_automat_SW.o: In function `manage_data':
src/TX_automat_SW.c:80: referencia a `format_frame' sin definir
[...]
As I think, solution is related with #ifndef #ifdef and #endif directives, but I've never used it... and I don't know how to do it...
First off anything you include that is not part of the standard or platform SDK should be included with double quotes #include "netfunc.h". Either your compiler will just ignore the difference between <> and "" or it will look in a different path.
So it looks like in your TX_automat_SW.c you are referencing something called "format_frame" that is not visitable to TX_automat_SW. It doesnt have anything to do with the #ifdef #endif statements. You are missing a #include in either TX_automat_SW.c or TX_automat_SW.h.
¿entiendes?
First off anything you include that is not part of the standard or platform SDK should be included with double quotes #include "netfunc.h". Either your compiler will just ignore the difference between <> and "" or it will look in a different path.
So it looks like in your TX_automat_SW.c you are referencing something called "format_frame" that is not visitable to TX_automat_SW. It doesnt have anything to do with the #ifdef #endif statements. You are missing a #include in either TX_automat_SW.c or TX_automat_SW.h.
¿entiendes?
Entiendo (o eso creo), gracias... But I couldn't solve my problem
I've replaced <> with "" around my .h files.
TX_automat_SW.c includes this: -
#include "TX_automat_SW.h"
-
#include "netfunc.h"
-
-
#include <unistd.h>
-
#include <stdio.h>
-
#include <stdlib.h>
-
#include <string.h>
-
When I run my make. -
sieira@GATTACA:/DOCS/Mis documentos/Estudios pendientes/Teleinformatica/LABORATORIO/Practica II/Programas$ make
-
gcc -g -c -Wall -I ./include src/IFTI_P2_automat.c -o src/IFTI_P2_automat.o
-
gcc -g -c -Wall -I ./include src/TX_automat_SW.c -o src/TX_automat_SW.o
-
gcc -g -c -Wall -I ./include src/TX_SW.c -o src/TX_SW.o
-
src/TX_SW.c: In function ‘main’:
-
src/TX_SW.c:26: error: ‘arguments’ undeclared (first use in this function)
-
src/TX_SW.c:26: error: (Each undeclared identifier is reported only once
-
src/TX_SW.c:26: error: for each function it appears in.)
-
src/TX_SW.c:26: error: expected ‘;’ before ‘args’
-
src/TX_SW.c:31: error: ‘frame’ undeclared (first use in this function)
-
src/TX_SW.c:31: error: expected ‘;’ before ‘inFrame’
-
src/TX_SW.c:32: error: ‘packet’ undeclared (first use in this function)
-
src/TX_SW.c:32: error: expected ‘;’ before ‘inPacket’
-
src/TX_SW.c:41: error: ‘MAX’ undeclared (first use in this function)
-
src/TX_SW.c:41: error: ‘args’ undeclared (first use in this function)
-
src/TX_SW.c:88: warning: implicit declaration of function ‘print_frame’
-
src/TX_SW.c:92: warning: implicit declaration of function ‘from_physical_layer’
-
src/TX_SW.c:92: error: ‘inFrame’ undeclared (first use in this function)
-
src/TX_SW.c:93: error: ‘CONTROL’ undeclared (first use in this function)
-
src/TX_SW.c:94: error: ‘ACK’ undeclared (first use in this function)
-
src/TX_SW.c:96: warning: implicit declaration of function ‘format_packet’
-
src/TX_SW.c:96: error: ‘inPacket’ undeclared (first use in this function)
-
make: *** [src/TX_SW.o] Error 1
-
(as you can see "gcc -g -c -Wall -I ./include src/TX_automat_SW.c -o src/TX_automat_SW.o" returns no errors)
Every error and warning refers to types and functions contained in "netfunc.h", and called from TX_SW.c so i include it. Since this header is included in both (TX_automat_SW.c and TX_SW.c) files. What I get is this: -
sieira@GATTACA:/DOCS/Mis documentos/Estudios pendientes/Teleinformatica/LABORATORIO/Practica II/Programas$ make
-
gcc -g -c -Wall -I ./include src/IFTI_P2_automat.c -o src/IFTI_P2_automat.o
-
gcc -g -c -Wall -I ./include src/TX_automat_SW.c -o src/TX_automat_SW.o
-
gcc -g -c -Wall -I ./include src/TX_SW.c -o src/TX_SW.o
-
gcc ./src/IFTI_P2_automat.o ./src/TX_automat_SW.o ./src/TX_SW.o -o bin/TX_SW
-
./src/TX_automat_SW.o: In function `manage_data':
-
src/TX_automat_SW.c:81: referencia a `format_frame' sin definir
-
./src/TX_automat_SW.o: In function `send_data_wait_response':
-
src/TX_automat_SW.c:95: referencia a `to_physical_layer' sin definir
-
./src/TX_SW.o: In function `main':
-
src/TX_SW.c:89: referencia a `print_frame' sin definir
-
src/TX_SW.c:93: referencia a `from_physical_layer' sin definir
-
src/TX_SW.c:96: referencia a `print_frame' sin definir
-
src/TX_SW.c:97: referencia a `format_packet' sin definir
-
src/TX_SW.c:110: referencia a `print_frame' sin definir
-
src/TX_SW.c:114: referencia a `from_physical_layer' sin definir
-
src/TX_SW.c:117: referencia a `print_frame' sin definir
-
src/TX_SW.c:118: referencia a `format_packet' sin definir
-
collect2: ld returned 1 exit status
-
make: *** [bin/TX_SW] Error 1
-
Now types get defined, and no error related is shown...but netfunc.h functions become undefined in both files...
I'm getting crazy...
I would be going crazy too. I took your code and compiled it with Visual Studio.NET and got no errors.
I has to add this: -
#define MAX 100
-
#define AUTOMAT_INITIAL_STATE 100
-
class TAutomat
-
{
-
-
};
-
class TEntity
-
{
-
-
};
-
class TState
-
{
-
-
};
-
class TEvent
-
{
-
-
};
-
class TEventArgs
-
{
-
-
};
-
just before the netfunc.h. I just made up values to see if it would compile.
My code looks like: -
#define MAX 100
-
#define AUTOMAT_INITIAL_STATE 100
-
class TAutomat
-
{
-
-
};
-
class TEntity
-
{
-
-
};
-
class TState
-
{
-
-
};
-
class TEvent
-
{
-
-
};
-
class TEventArgs
-
{
-
-
};
-
///////////////////////////////////////////
-
//netfunc.h
-
typedef struct{
-
char data[MAX];
-
int n;
-
}packet;
-
-
typedef struct
-
{
-
char flag_s;
-
char address;
-
unsigned char control;
-
char data[MAX];
-
unsigned char FCS1;
-
unsigned char FCS2;
-
char flag_e;
-
}frame;
-
-
typedef struct{
-
frame trama;
-
packet paquete;
-
FILE* file;
-
int tty;
-
}arguments;
-
-
-
void to_physical_layer(frame *fr, int fds);
-
void from_physical_layer(frame *fr, int fde);
-
void print_frame(frame trama);
-
void format_frame(frame *fs, packet ps,int control);
-
void format_packet(frame fs, packet *ps);
-
void to_network_layer (packet pr, FILE *pfs);
-
-
///////////////////////////////
-
int main()
-
{
-
-
-
///////////////////////////////////////////
-
/* ----------------------------------------------------------- *
-
* Author: Luis Sieira García <email removed>
-
* Date: May 2007
-
* No rights reserved
-
* ----------------------------------------------------------- */
-
//#include <IFTI_P2_automat.h>
-
-
#define REACHED_EOF 3
-
-
-
-
/* ------------------------------------------------------------
-
* State definitions
-
* ------------------------------------------------------------ */
-
enum {
-
TX_STATE_INITIAL = AUTOMAT_INITIAL_STATE,
-
TX_STATE_READING,
-
TX_STATE_FRAMING,
-
TX_STATE_WAITING
-
};
-
-
/* ------------------------------------------------------------
-
* Event definitions
-
* ------------------------------------------------------------ */
-
enum {
-
TX_EV_OPERATIVE = 1,
-
TX_EV_READOK,
-
TX_EV_FRAMED,
-
TX_EV_TWOFRAMES,
-
TX_EV_ACK_RECEIVED,
-
};
-
-
/* ------------------------------------------------------------
-
* Action definitions
-
* ------------------------------------------------------------ */
-
TAutomat * TX_automat_SW_define( );
-
-
int read_data( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
int manage_data( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
int send_data_wait_response( TEntity * inEntity,
-
TState inFromState,
-
TEvent inEvent,
-
TEventArgs * inArgs );
-
-
-
/////////////////////////////////////////////////
-
-
}
Thank you, I was not getting crazy. I was stupid...
I wondered "why didn't compile for me if the code has no errors?"
Obviously the problem was in my Makefile -
CC=gcc
-
CXX=gcc
-
INCLUDES=-I ./include
-
CFLAGS=-g -c -Wall
-
LDFLAGS=
-
SOURCES=./src/IFTI_P2_automat.c ./src/TX_automat_SW.c ./src/TX_SW.c
-
OBJECTS=$(SOURCES:.c=.o)
-
EXECUTABLE1=./bin/TX_SW
-
EXECUTABLE2=./bin/RX_SW
-
-
all: $(SOURCES) $(EXECUTABLE1) $(EXECUTABLE2)
-
-
$(EXECUTABLE1): $(OBJECTS)
-
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
-
-
$(EXECUTABLE2): $(OBJECTS)
-
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
-
-
.c.o:
-
$(CC) $(CFLAGS) $(INCLUDES) $< -o $@
-
-
clean:
-
\rm -rf $(OBJECTS) $(EXECUTABLE1) $(EXECUTABLE2)
-
I forgot to add ./src/netfunc.c in the SOURCES tag!!!
I don't use to write Makefiles this way... so I didn't see it.
Thousands of thanks
You gotta trade that thing in for an IDE that does the makefiles for you.
Banfa 9,065
Recognized Expert Moderator Expert
You gotta trade that thing in for an IDE that does the makefiles for you.
You know that sometimes you just don't get a choice, particularly if you want to do management of multi-platform code.
Most platforms compilers do not come with an IDE.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ken Allen |
last post by:
I have been developing a suite of assemblies over the past couple of weeks,
and this afternoon somethign started misbehaving.
If I do not run the IDE and compiler the code from the command line,...
|
by: Alan Krueger |
last post by:
Is there a way to automatically include C# files (.cs) generated by a
third-party tool into a Visual C# .NET build? It's possible the set
of files generated by this tool might change. Adding...
|
by: Brian Henry |
last post by:
This has worked perfectly for the past year now all the sudden it will not
compile the installer project correctly. All our source code is in a Source
Safe database so every system we do this on...
|
by: Keith Jakobs, MCP |
last post by:
Hi All....
I'm having a HECK of a time connecting to Active Directory using VB in
Visual Studio.NET 2003. Can anyone PLEASE help me?
All I am trying to do is list the current members of our...
|
by: shruti |
last post by:
hiii all
I'm tryin to call a perl script from a C program in following 2 ways-
1.By callin system function.
But there's some problem because the system function is not able to
executeany...
| |
by: rohinichandrap |
last post by:
Hi,
I am facing a strange problem with the .pdb files in one of the project
workspaces I am working with.This is during an upgrade from Visual
studio 6.0 to Visual Studio .Net 2003.
The...
|
by: anupamak |
last post by:
hello,
I created a win32 project(precompiled headers, console application). This was created to create a service( for which i used SERVICE_TABLE_ENTRY, SERVICE_STATUS, SERVICE_STATUS_HANDLE,...
|
by: ZMY |
last post by:
Dear all,
I am a real newbie for both python and QNX, but I am still trying to
compile Numeric-24.2 under QNX4.25 with python 2.2. I got following
error message:
$ sudo python setup.py...
|
by: james.mcdonagh |
last post by:
Hi I am a newbie using nAnt for .net 2.0. As such I have not come
across this bug before, and I would be happy of any help that you may
be able to provide.
In order to help I have included the...
|
by: yxq |
last post by:
Hello,
I want to build the multi-language application with the xml file, how to do?
could anyone tell a sample?
Thank you
|
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,...
| |
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |