This is the mail archive of the
cygwin
mailing list for the Cygwin project.
how come #include "*.cpp" works?
- From: Klaas Thoelen <klaas dot thoelen at telenet dot be>
- To: cygwin at cygwin dot com
- Date: Thu, 11 May 2006 21:09:33 +0200
- Subject: how come #include "*.cpp" works?
Hello *,
I recently installed cygwin to freshen up my C/C++, what I didn't want
to do using huge programs like visual studio. It seemed to work fine
until I came across the following problem.
I have 3 files: datum.h
datum.cpp
datumprint.cpp (which has my main in it)
In 'datum.cpp' I include 'datum.h' as I should, and in 'datumprint.cpp'
also. But this gives me compile-errors about members of my class Date
being undefined. However, if I include 'datum.cpp' in 'datumprint.cpp'
it works just fine!
This seems a little strange to me. Does anybody know what's wrong here?
Thanks and regards,
Klaas Thoelen
datum.h
******
class Date {
public:
Date();
Date(int dd, int mm, int yy);
int day();
int month();
int year();
static void set_default(int, int, int);
Date& add_year(int);
Date& add_month(int);
Date& add_day(int);
Date& print();
private:
int d, m, y;
static Date default_date;
static bool is_leapyear(int);
static int daysinmonth(int, int);
};
datum.cpp
********
#include "datum.h"
#include <iostream>
#include <assert.h>
using namespace std;
Date Date::default_date(27, 4, 2006);
Date::Date() {
d = default_date.d;
m = default_date.m;
y = default_date.y;
}
Date::Date(int dd, int mm, int yy) {
assert ( !(dd < 1) && !(dd > daysinmonth(mm, yy)) && !(mm < 1) &&
!(mm > 12) );
d = dd;
m = mm;
y = yy;
}
void Date::set_default(int dd, int mm, int yy) {
assert ( !(dd < 1) && !(dd > daysinmonth(mm, yy)) && !(mm < 1) &&
!(mm > 12) );
default_date.d = dd;
default_date.m = mm;
default_date.y = yy;
}
int Date::day() {
return d;
}
int Date::month() {
return m;
}
int Date::year() {
return y;
}
Date& Date::add_year(int yy) {
y = y + yy;
if ( d == 29 && m == 2 && !is_leapyear(y) ) {
d = 1;
m = 3;
}
return *this;
}
Date& Date::add_month(int mm) {
m = m + mm;
while (m > 12) {
m = m - 12;
y++;
}
if ( d == 29 && m == 2 && !is_leapyear(y) ) {
d = 1;
m = 3;
}
if ( d > daysinmonth(m, y)) {
d = d - daysinmonth(m, y);
m++;
}
return *this;
}
Date& Date::add_day(int dd) {
d = d + dd;
while (d > daysinmonth(m, y)) {
if (m == 12) {
y++;
d = d - daysinmonth(m, y);
m = 1;
} else {
d = d - daysinmonth(m, y);
m++;
}
}
return *this;
}
Date& Date::print() {
cout << d << "/" << m << "/" << y << "\n";
return *this;
}
bool Date::is_leapyear(int yy) {
if (( !(yy % 4) && (yy % 100)) || !(yy % 400)) {
return true;
}
return false;
}
int Date::daysinmonth(int mm, int yy) {
if ( (mm == 2) && is_leapyear(yy) ) {
return 29;
} else{
int nr_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
return nr_days[mm-1];
}
}
datumprint.cpp
***********
#include "datum.h" /***********the problem*************/
#include <iostream>
using namespace std;
void print(Date x) {
cout << x.day() << "/" << x.month() << "/" << x.year() << "\n";
}
int main() {
Date::set_default(2, 12, 2007);
Date x;
print(x);
x.add_day(365);
print(x);
Date y(22, 12, 1999);
y.add_day(70);
print(y);
Date z(29, 2, 1896);
z.add_year(4);
print(z);
Date r(29, 2, 1896);
r.add_month(24);
print(r);
Date s(31, 05, 1896);
s.add_month(25);
print(s);
return 0;
}
Cygwin Configuration Diagnostics
Current System Time: Thu May 11 20:45:35 2006
Windows XP Professional Ver 5.1 Build 2600 Service Pack 2
Path: D:\cygwin\usr\local\bin
D:\cygwin\bin
D:\cygwin\bin
D:\cygwin\usr\X11R6\bin
D:\cygwin\home\klaas\c++
D:\cygwin\usr\local\bin
D:\cygwin\bin
D:\cygwin\bin
D:\cygwin\usr\X11R6\bin
d:\Program Files\Insightful\splus70\
d:\WINDOWS\system32
d:\WINDOWS
d:\WINDOWS\System32\Wbem
d:\Program Files\QuickTime\QTSystem\
d:\PROGRA~1\ULTRAE~1
Output from D:\cygwin\bin\id.exe (nontsec)
UID: 1003(klaas) GID: 513(None)
0(root) 513(None) 544(Administrators)
545(Users) 1004(Debugger Users)
Output from D:\cygwin\bin\id.exe (ntsec)
UID: 1003(klaas) GID: 513(None)
0(root) 513(None) 544(Administrators)
545(Users) 1004(Debugger Users)
SysDir: D:\WINDOWS\system32
WinDir: D:\WINDOWS
USER = 'klaas'
PWD = '/home/klaas/c++'
HOME = '/home/klaas'
MAKE_MODE = 'unix'
HOMEPATH = '\Documents and Settings\klaas'
MANPATH = '/usr/local/man:/usr/share/man:/usr/man:'
APPDATA = 'D:\Documents and Settings\klaas\Application Data'
HOSTNAME = 'amd-klaas'
VS71COMNTOOLS = 'D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\'
TERM = 'cygwin'
PROCESSOR_IDENTIFIER = 'x86 Family 15 Model 31 Stepping 0, AuthenticAMD'
WINDIR = 'D:\WINDOWS'
OLDPWD = '/home/klaas'
USERDOMAIN = 'AMD-KLAAS'
OS = 'Windows_NT'
ALLUSERSPROFILE = 'D:\Documents and Settings\All Users'
!:: = '::\'
TEMP = '/cygdrive/d/DOCUME~1/klaas/LOCALS~1/Temp'
COMMONPROGRAMFILES = 'D:\Program Files\Common Files'
LIB = 'D:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\'
QTJAVA = 'D:\Program Files\Java\jre1.5.0_04\lib\ext\QTJava.zip'
USERNAME = 'klaas'
PROCESSOR_LEVEL = '15'
FP_NO_HOST_CHECK = 'NO'
SYSTEMDRIVE = 'D:'
USERPROFILE = 'D:\Documents and Settings\klaas'
PS1 = '\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
LOGONSERVER = '\\AMD-KLAAS'
PROCESSOR_ARCHITECTURE = 'x86'
SHLVL = '1'
PATHEXT = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH'
HOMEDRIVE = 'D:'
!D: = 'D:\cygwin\bin'
PROMPT = '$P$G'
COMSPEC = 'D:\WINDOWS\system32\cmd.exe'
TMP = '/cygdrive/d/DOCUME~1/klaas/LOCALS~1/Temp'
SYSTEMROOT = 'D:\WINDOWS'
PRINTER = 'Microsoft Office Document Image Writer'
CVS_RSH = '/bin/ssh'
PROCESSOR_REVISION = '1f00'
CLASSPATH = 'D:\Program Files\Java\jre1.5.0_04\lib\ext\QTJava.zip'
INFOPATH = '/usr/local/info:/usr/share/info:/usr/info:'
PROGRAMFILES = 'D:\Program Files'
NUMBER_OF_PROCESSORS = '1'
INCLUDE = 'D:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\'
SESSIONNAME = 'Console'
COMPUTERNAME = 'AMD-KLAAS'
_ = '/usr/bin/cygcheck'
POSIXLY_CORRECT = '1'
HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2
(default) = '/cygdrive'
cygdrive flags = 0x00000022
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/
(default) = 'D:\cygwin'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
(default) = 'D:\cygwin/bin'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
(default) = 'D:\cygwin/lib'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options
a: fd N/A N/A
c: hd NTFS 16323Mb 1% CP CS UN PA FC
d: hd NTFS 60000Mb 33% CP CS UN PA FC
e: hd NTFS 39997Mb 57% CP CS UN PA FC
f: hd NTFS 39997Mb 1% CP CS UN PA FC
h: cd CDFS 0Mb -2147483548% CS Audio CD
i: cd N/A N/A
D:\cygwin / system binmode
D:\cygwin/bin /usr/bin system binmode
D:\cygwin/lib /usr/lib system binmode
. /cygdrive system binmode,cygdrive
Found: D:\cygwin\bin\awk.exe
Found: D:\cygwin\bin\bash.exe
Found: D:\cygwin\bin\cat.exe
Found: D:\cygwin\bin\cp.exe
Found: D:\cygwin\bin\cpp.exe
Not Found: crontab
Found: D:\cygwin\bin\find.exe
Found: D:\cygwin\bin\gcc.exe
Not Found: gdb
Found: D:\cygwin\bin\grep.exe
Found: D:\cygwin\bin\kill.exe
Found: D:\cygwin\bin\ld.exe
Found: D:\cygwin\bin\ls.exe
Not Found: make
Found: D:\cygwin\bin\mv.exe
Not Found: patch
Not Found: perl
Found: D:\cygwin\bin\rm.exe
Found: D:\cygwin\bin\sed.exe
Not Found: ssh
Found: D:\cygwin\bin\sh.exe
Found: D:\cygwin\bin\tar.exe
Found: D:\cygwin\bin\test.exe
Not Found: vi
Not Found: vim
56k 2005/07/09 D:\cygwin\bin\cygbz2-1.dll - os=4.0 img=1.0 sys=4.0
"cygbz2-1.dll" v0.0 ts=2005/7/9 7:09
7k 2005/11/20 D:\cygwin\bin\cygcharset-1.dll - os=4.0 img=1.0 sys=4.0
"cygcharset-1.dll" v0.0 ts=2005/11/20 3:24
7k 2003/10/19 D:\cygwin\bin\cygcrypt-0.dll - os=4.0 img=1.0 sys=4.0
"cygcrypt-0.dll" v0.0 ts=2003/10/19 9:57
40k 2006/03/24 D:\cygwin\bin\cygform-8.dll - os=4.0 img=1.0 sys=4.0
"cygform-8.dll" v0.0 ts=2006/3/24 8:16
45k 2001/04/25 D:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0
"cygform5.dll" v0.0 ts=2001/4/25 7:28
35k 2002/01/09 D:\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0
"cygform6.dll" v0.0 ts=2002/1/9 7:03
48k 2003/08/09 D:\cygwin\bin\cygform7.dll - os=4.0 img=1.0 sys=4.0
"cygform7.dll" v0.0 ts=2003/8/9 11:25
28k 2003/07/20 D:\cygwin\bin\cyggdbm-3.dll - os=4.0 img=1.0 sys=4.0
"cyggdbm-3.dll" v0.0 ts=2003/7/20 9:58
30k 2003/08/11 D:\cygwin\bin\cyggdbm-4.dll - os=4.0 img=1.0 sys=4.0
"cyggdbm-4.dll" v0.0 ts=2003/8/11 4:12
19k 2003/03/22 D:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0
"cyggdbm.dll" v0.0 ts=2002/2/20 4:05
15k 2003/07/20 D:\cygwin\bin\cyggdbm_compat-3.dll - os=4.0 img=1.0 sys=4.0
"cyggdbm_compat-3.dll" v0.0 ts=2003/7/20 10:00
15k 2003/08/11 D:\cygwin\bin\cyggdbm_compat-4.dll - os=4.0 img=1.0 sys=4.0
"cyggdbm_compat-4.dll" v0.0 ts=2003/8/11 4:13
17k 2001/06/28 D:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0
"cyghistory4.dll" v0.0 ts=2001/1/7 5:34
29k 2003/08/10 D:\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0
"cyghistory5.dll" v0.0 ts=2003/8/11 1:16
24k 2006/03/25 D:\cygwin\bin\cyghistory6.dll - os=4.0 img=1.0 sys=4.0
"cyghistory6.dll" v0.0 ts=2006/3/25 15:05
947k 2005/11/20 D:\cygwin\bin\cygiconv-2.dll - os=4.0 img=1.0 sys=4.0
"cygiconv-2.dll" v0.0 ts=2005/11/20 3:24
22k 2001/12/13 D:\cygwin\bin\cygintl-1.dll - os=4.0 img=1.0 sys=4.0
"cygintl-1.dll" v0.0 ts=2001/12/13 10:28
37k 2003/08/10 D:\cygwin\bin\cygintl-2.dll - os=4.0 img=1.0 sys=4.0
"cygintl-2.dll" v0.0 ts=2003/8/10 23:50
31k 2005/11/20 D:\cygwin\bin\cygintl-3.dll - os=4.0 img=1.0 sys=4.0
"cygintl-3.dll" v0.0 ts=2005/11/20 3:04
21k 2001/06/20 D:\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0
"cygintl.dll" v0.0 ts=2001/6/20 19:09
21k 2006/03/24 D:\cygwin\bin\cygmenu-8.dll - os=4.0 img=1.0 sys=4.0
"cygmenu-8.dll" v0.0 ts=2006/3/24 8:16
26k 2001/04/25 D:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0
"cygmenu5.dll" v0.0 ts=2001/4/25 7:27
20k 2002/01/09 D:\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0
"cygmenu6.dll" v0.0 ts=2002/1/9 7:03
29k 2003/08/09 D:\cygwin\bin\cygmenu7.dll - os=4.0 img=1.0 sys=4.0
"cygmenu7.dll" v0.0 ts=2003/8/9 11:25
67k 2006/03/24 D:\cygwin\bin\cygncurses++-8.dll - os=4.0 img=1.0 sys=4.0
"cygncurses++-8.dll" v0.0 ts=2006/3/24 8:17
156k 2001/04/25 D:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0
"cygncurses++5.dll" v0.0 ts=2001/4/25 7:29
175k 2002/01/09 D:\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0 sys=4.0
"cygncurses++6.dll" v0.0 ts=2002/1/9 7:03
227k 2006/03/24 D:\cygwin\bin\cygncurses-8.dll - os=4.0 img=1.0 sys=4.0
"cygncurses-8.dll" v0.0 ts=2006/3/24 5:51
226k 2001/04/25 D:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0
"cygncurses5.dll" v0.0 ts=2001/4/25 7:17
202k 2002/01/09 D:\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0
"cygncurses6.dll" v0.0 ts=2002/1/9 7:03
224k 2003/08/09 D:\cygwin\bin\cygncurses7.dll - os=4.0 img=1.0 sys=4.0
"cygncurses7.dll" v0.0 ts=2003/8/9 11:24
12k 2006/03/24 D:\cygwin\bin\cygpanel-8.dll - os=4.0 img=1.0 sys=4.0
"cygpanel-8.dll" v0.0 ts=2006/3/24 8:16
15k 2001/04/25 D:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0
"cygpanel5.dll" v0.0 ts=2001/4/25 7:27
12k 2002/01/09 D:\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0
"cygpanel6.dll" v0.0 ts=2002/1/9 7:03
19k 2003/08/09 D:\cygwin\bin\cygpanel7.dll - os=4.0 img=1.0 sys=4.0
"cygpanel7.dll" v0.0 ts=2003/8/9 11:24
176k 2005/09/06 D:\cygwin\bin\cygpcre-0.dll - os=4.0 img=1.0 sys=4.0
"cygpcre-0.dll" v0.0 ts=2005/9/6 22:49
299k 2005/09/06 D:\cygwin\bin\cygpcrecpp-0.dll - os=4.0 img=1.0 sys=4.0
"cygpcrecpp-0.dll" v0.0 ts=2005/9/6 23:26
6k 2005/09/06 D:\cygwin\bin\cygpcreposix-0.dll - os=4.0 img=1.0 sys=4.0
"cygpcreposix-0.dll" v0.0 ts=2005/9/6 23:26
22k 2002/06/09 D:\cygwin\bin\cygpopt-0.dll - os=4.0 img=1.0 sys=4.0
"cygpopt-0.dll" v0.0 ts=2002/6/9 7:45
108k 2001/06/28 D:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0
"cygreadline4.dll" v0.0 ts=2001/1/7 5:34
148k 2003/08/10 D:\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0 sys=4.0
"cygreadline5.dll" v0.0 ts=2003/8/11 1:16
152k 2006/03/25 D:\cygwin\bin\cygreadline6.dll - os=4.0 img=1.0 sys=4.0
"cygreadline6.dll" v0.0 ts=2006/3/25 15:05
65k 2005/08/23 D:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
"cygz.dll" v0.0 ts=2005/8/23 4:03
1763k 2006/01/20 D:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
"cygwin1.dll" v0.0 ts=2006/1/20 19:28
Cygwin DLL version info:
DLL version: 1.5.19
DLL epoch: 19
DLL bad signal mask: 19005
DLL old termios: 5
DLL malloc env: 28
API major: 0
API minor: 150
Shared data: 4
DLL identifier: cygwin1
Mount registry: 2
Cygnus registry name: Cygnus Solutions
Cygwin registry name: Cygwin
Program options name: Program Options
Cygwin mount registry name: mounts v2
Cygdrive flags: cygdrive flags
Cygdrive prefix: cygdrive prefix
Cygdrive default prefix:
Build date: Fri Jan 20 13:28:43 EST 2006
CVS tag: cr-0x5ef
Shared id: cygwin1S4
Can't find the cygrunsrv utility, skipping services check.
Cygwin Package Information
Last downloaded files to: D:\Documents and Settings\klaas\Desktop
Last downloaded files from: ftp://ftp.easynet.be/cygwin
Package Version
_update-info-dir 00390-1
alternatives 1.3.20a-2
ash 20040127-3
base-files 3.7-1
base-passwd 2.2-1
bash 3.1-5
binutils 20050610-1
bzip2 1.0.3-1
coreutils 5.94-1
crypt 1.1-1
cygutils 1.3.0-1
cygwin 1.5.19-4
cygwin-doc 1.4-3
diffutils 2.8.7-1
editrights 1.01-1
findutils 4.2.27-1
gawk 3.1.5-4
gcc 3.3.3-3
gcc-core 3.4.4-1
gcc-g++ 3.4.4-1
gcc-mingw-core 20050522-1
gcc-mingw-g++ 20050522-1
gdbm 1.8.3-7
grep 2.5.1a-2
groff 1.18.1-2
gzip 1.3.5-1
less 381-1
libbz2_1 1.0.3-1
libcharset1 1.9.2-2
libgdbm 1.8.0-5
libgdbm-devel 1.8.3-7
libgdbm3 1.8.3-3
libgdbm4 1.8.3-7
libiconv 1.9.2-2
libiconv2 1.9.2-2
libintl 0.10.38-3
libintl1 0.10.40-1
libintl2 0.12.1-3
libintl3 0.14.5-1
libncurses5 5.2-1
libncurses6 5.2-8
libncurses7 5.3-4
libncurses8 5.5-2
libpcre0 6.3-1
libpopt0 1.6.4-4
libreadline4 4.1-2
libreadline5 4.3-5
libreadline6 5.1-5
login 1.9-7
man 1.5p-1
mingw-runtime 3.9-2
mktemp 1.5-3
ncurses 5.5-2
run 1.1.9-1
sed 4.1.5-1
tar 1.15.1-4
termcap 20050421-1
terminfo 5.5_20060323-1
texinfo 4.8-1
w32api 3.7-1
which 1.7-1
zlib 1.2.3-1
Use -h to see help about each section
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/