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 1773 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_fra me" 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_fra me" 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, the
compilation seems to work properly almost all of the time. More on this
later.
If I launch one copy of the IDE, then I can usually compile the project at
least once. At some point, the build fails reporting "Could not copy
temporary files...
|
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 these files
manually to the project would work in the short term, but this would
require manual intervention if these generated files happened to
change, and I'd like to avoid any unnecessary manual steps.
NAnt and similar tools can include and...
|
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 should be identicle. On one
system the installer project will compile correctly, but on two others it
will fail with this error.
------ Rebuild All started: Project: Installer, Configuration: Debug ------
Building file 'T:\Current Builds...
|
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 Active Directory on
a web page. If I can connect to the AD interfaces, then I think I can
handle it from there.
I do have a VS.NET C# project successfully working and enumerating names,
|
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 command...it just returns -1.
2.By using the code given in perldoc perlembed(perl documentation for
embedding perl in C)
| |
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 workspace has two projects A,B.
When I build project A it asks for a checkout of the B.pdb file along
with A.exe,.map,.pdb.
When I build project B it asks for a checkout of the A.pdb file along
|
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, etc... required structures and methods).
Environment used:
Windows XP, VC++.Net2005.
Should work on:
I want to make this exe to run on windows 95,98, XP, 2000 and Vista.
|
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 install
Password:
running install
|
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 nant file which is causing the
problem, the object code that is not being built and the error message
which is being produced.
The weird thing is that VS.net builds without a problem. And the
intellisense within the object WorkQueue knows that...
|
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: 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,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |