Dear all,
I have written my own function by C. And my development platform is
W2k with VC6.0.
Then I also defined a header file to extern declare this function.
After that, I include this header file.
The function is stored in C:\temp\myfun.c
int func(){
return 1;
}
The header file is stored in C:\temp\myheade r.h
extern int func(void);
in my main program, I got a problem if I include this header file
(myheader.h).
#include <stdio.h>
#include "C:\temp\myhead er.h"
void main(){
func();
}
This main program is not in c:\temp\ folder.
The error message is {
--------------------Configuration: pureC_test - Win32
Debug--------------------
Compiling...
main.c
Linking...
main.obj : error LNK2001: unresolved external symbol _func
Debug/pureC_test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...
pureC_test.exe - 2 error(s), 0 warning(s)
}
BUT if I copy the myfun.c & myheader.h in the same path as the main
program. It works fine.
Can anybody help me to solve this problem??
Thank you very much.
Alan 6 7065
alan wrote:
.... snip ... The function is stored in C:\temp\myfun.c int func(){ return 1; }
The header file is stored in C:\temp\myheade r.h extern int func(void);
in my main program, I got a problem if I include this header file (myheader.h). #include <stdio.h> #include "C:\temp\myhead er.h"
Those backslashes are escape characters. \t means a tab char. \m
is not defined, but most likely is taken as m. Either use forward
slashes, or double the backslashes.
.... snip ... Can anybody help me to solve this problem??
--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
In article <7b************ **************@ posting.google. com>, ch***********@i-cable.com says... in my main program, I got a problem if I include this header file (myheader.h). #include <stdio.h> #include "C:\temp\myhead er.h"
This is all off-topic for CLC, which only talks about the standard
C language, not compiler-specific build environments and their
problems. One of the microsoft newsgroups is probably your best
bet.
However... Using VC, without an external make file, the usual way of
doing this is to add the directory to your include path in the
project itself, then simply use
#include "myhdeader. h" void main(){ func(); }
This main program is not in c:\temp\ folder. The error message is { --------------------Configuration: pureC_test - Win32 Debug-------------------- Compiling... main.c Linking...
Notice, it never compiled myfun.c. That's because the source file also
must be added to the project. The unresolved external is due to there
not being an object file containing func(). Add the source file, do
a build all, and you should be good to go.
CBFalconer <cb********@yah oo.com> wrote in message news:<3F******* ********@yahoo. com>... alan wrote: ... snip ... The function is stored in C:\temp\myfun.c int func(){ return 1; }
The header file is stored in C:\temp\myheade r.h extern int func(void);
in my main program, I got a problem if I include this header file (myheader.h). #include <stdio.h> #include "C:\temp\myhead er.h"
Those backslashes are escape characters. \t means a tab char. \m is not defined, but most likely is taken as m. Either use forward slashes, or double the backslashes.
It's true.In addition,the content of 'myheader.h' should be
int func(void);
The word of extern isn't needed. ... snip ... Can anybody help me to solve this problem??
CBFalconer wrote: alan wrote: ... snip ... The function is stored in C:\temp\myfun.c int func(){ return 1; }
The header file is stored in C:\temp\myheade r.h extern int func(void);
in my main program, I got a problem if I include this header file (myheader.h). #include <stdio.h> #include "C:\temp\myhead er.h"
Those backslashes are escape characters. \t means a tab char. \m is not defined, but most likely is taken as m. Either use forward slashes, or double the backslashes.
Nit-pick: The backslashes are *not* escape sequences,
and \t does *not* mean a tab character. The stuff between
the double quotes is a "q-char-sequence," *not* a string
literal.
6.4.7 Header names
/3/ [...] Similarly, if the characters ', \, //, or /*
occur in the sequnce between the " delimiters, the
behavior is undefined(68)
68) Thus, sequences of characters that resemble escape
sequences cause undefined behavior.
The practical consequence is that the form of header names
is platform-dependent, and it's up to the platform to decide
what (if anything) to do with backslashes and the like. The
O.P.'s compiler may or may not accept them -- and doubling
the backslashes may or may not cure the problem.
-- Er*********@sun .com
sorry, I made a type mistake on path slash char.
I repeat my question.
I defined a header file to extern declare this function.
After that, I include this header file.
The function is stored in C:\\temp\\myfun .c
int func(){
return 1;
}
The header file is stored in C:\\temp\\myhea der.h
extern int func(void);
in my main program, I got a problem if I include this header file
(myheader.h).
#include <stdio.h>
#include "C:\\temp\\myhe ader.h"
void main(){
func();
}
The main program , say "main.c" is stored in another location.
But if I copy the myfunc.c & myheader.h to the same path of "main.c",
it works fine.
My question is why my main.c program cannot locate "myfunc.c" & "myheader.h " file ??
Can anybody help me?
Pls help!!
Thank you very much.
Randy Howard <ra**********@F OOmegapathdslBA R.net> wrote in message news:<MP******* *************** **@news.megapat hdsl.net>... In article <7b************ **************@ posting.google. com>, ch***********@i-cable.com says... in my main program, I got a problem if I include this header file (myheader.h). #include <stdio.h> #include "C:\temp\myhead er.h"
This is all off-topic for CLC, which only talks about the standard C language, not compiler-specific build environments and their problems. One of the microsoft newsgroups is probably your best bet.
However... Using VC, without an external make file, the usual way of doing this is to add the directory to your include path in the project itself, then simply use #include "myhdeader. h"
void main(){ func(); }
This main program is not in c:\temp\ folder. The error message is { --------------------Configuration: pureC_test - Win32 Debug-------------------- Compiling... main.c Linking...
Notice, it never compiled myfun.c. That's because the source file also must be added to the project. The unresolved external is due to there not being an object file containing func(). Add the source file, do a build all, and you should be good to go.
In article <7b************ **************@ posting.google. com>, ch***********@i-cable.com says... My question is why my main.c program cannot locate "myfunc.c" & "myheader.h " file ??
Can anybody help me?
Pls help!!
I already answered your question, included in the quoted text of your
reply. I give up. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: aa |
last post by:
Is it OK to include an ANSI file into a UTF-8 file?
|
by: Ramesh |
last post by:
Hi,
I am currently maintaining a legacy code with a very very large code base.
I am facing problems with C/C++ files having a lot of un-necessary #includes.
On an average every C/C++ file has around 150+ .h files included. I find 75%
of the files unnecessary and could be removed. Considering the fact that I
have a huge code base, I can't manually fix it.
Are there any tools that would report un wanted .h files?
|
by: Derrick Coetzee |
last post by:
It seems like, in every C source file I've ever seen, there has been a
very definite include order, as follows:
- include system headers
- include application headers
- include the header associated with this source file
For example, in a file hello.c:
#include <stdio.h>
|
by: Francois Grieu |
last post by:
Can #include safely use a preprocessing token, as in
#define HEADERFILE "stdio.h"
#include HEADERFILE
int main(void) {return printf("Hello, world\n")*0;}
TIA,
François Grieu
|
by: zolli |
last post by:
Hi,
I've been banging my head against this for a while now. Hoping someone
here can shed some light on what's going on.
On including stdlib.h in a file, I'm seeing the following errors:
----BEGIN ERRORS----
gcc -g3 -DUSE_LIBC -Wall -c -I../mm -I../include -I/usr/include
-I/usr/include/linux -o mm_tree_test.o mm_tree_test.c
| |
by: Jon Rea |
last post by:
I am currently cleaning up an application which was origainlly hashed
together with speed of coding in mind and therefore contains quite a few
"hacky" shortcuts.
As part of this "revamping" process I am introducing namespaces to
properly compartmentalise sections of the code into logical units. What
I am speciffically trying to get right is the dependency tree for header
files to reduce compile time and simplify the code structure.
On...
|
by: chat |
last post by:
Hi, every body.
I have 3 files like this:
--------------------------------------------------------
file name : header.h
#ifndef TEST_H
#define TEST_H
int a=1;
double b=0.5;
|
by: rbhlgjwbvi |
last post by:
I have a header whose filename contains an embedded newline and I can't
seem to #include it successfully. I've tried
#include "my
file.h"
and
#include "my\nfile.h"
|
by: The Cool Giraffe |
last post by:
One thing i do know for sure. When one creates a CPP file,
one needs to include the H file. Now, having said that, i
wonder if there are some general hints, requirements or
standard guide lines on what and how to include.
Suppose that we have a project consisting of a number of
classes and structs. Some of them using the others, some
using all of them. What is a good approach when including?
--
|
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...
|
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: 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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: 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.
| |