I have thought about it, and the only way I can think of to scale it down is to
use more strings, but main() is still going to be ginormous, because
- I can't reduce the several hundred different strings I am comparing an
argument against (40 strings per each of about 40 if statement's conditionals,
although I could stick it in an array, that just moves the problem, but it gets
it off the stack maybe)
- I can maybe modularize about 10 lines of each of the 40 if statement's then
block, small though it is, so that I use a STL map instead of a class, or
change the way I access the class, using strings. this would increase the
number of static strings in the program. with a map you can do
field["abc"]="xyz"; or field[string("abc")]=string("xyz"); so I could do that
instead of accessing the class members directly like object.has_id=true; and
object.id=string("348723");
the part that concerns me most is I have 5582 strings in phonelist.cpp and 5578
strings in guibackend.cpp. I would attach the code to show you, but I can't
attach anything because yahoo mail is broken right now.
it turns out WinMain() is only 4000 lines long, the rest is taken up by 15 or
so
large functions. I had to actually look to see.
here is a sample of the if statements.
this is an embedded SQL program.
there is a lot of other code as well, huge functions due to the same problem..
this code would be reduced by a factor of at least 4 if I could have
case-insensive compares in the STL string template. but alas, I am not smart
enough to mod it, I don't write compilers anymore since college 30 years ago,
and my code doesn't compile, and I am not getting anywhere. I am out of
memory. the compiler executes for about 5 minuites, then gives up with the
error message I told you about. and it generates a big executable that does
nothing.
else if (argc>=2 && (
0==argv[argvi+0].compare("--companypostalcode")||
0==argv[argvi+0].compare("--CompanyPostalcode")||
0==argv[argvi+0].compare("--CompanyPostalCode")||
0==argv[argvi+0].compare("--COMPANYPOSTALCODE")||
0==argv[argvi+0].compare("--companyzip")||
0==argv[argvi+0].compare("--CompanyZip")||
0==argv[argvi+0].compare("--COMPANYZIP")||
0==argv[argvi+0].compare("--companyzipcode")||
0==argv[argvi+0].compare("--CompanyZipcode")||
0==argv[argvi+0].compare("--CompanyZipCode")||
0==argv[argvi+0].compare("--COMPANYZIPCODE")||
0==argv[argvi+0].compare("-companypostalcode")||
0==argv[argvi+0].compare("-CompanyPostalcode")||
0==argv[argvi+0].compare("-CompanyPostalCode")||
0==argv[argvi+0].compare("-COMPANYPOSTALCODE")||
0==argv[argvi+0].compare("-companyzip")||
0==argv[argvi+0].compare("-CompanyZip")||
0==argv[argvi+0].compare("-COMPANYZIP")||
0==argv[argvi+0].compare("-companyzipcode")||
0==argv[argvi+0].compare("-CompanyZipcode")||
0==argv[argvi+0].compare("-CompanyZipCode")||
0==argv[argvi+0].compare("-COMPANYZIPCODE")||
0==argv[argvi+0].compare("/companypostalcode")||
0==argv[argvi+0].compare("/CompanyPostalcode")||
0==argv[argvi+0].compare("/CompanyPostalCode")||
0==argv[argvi+0].compare("/COMPANYPOSTALCODE")||
0==argv[argvi+0].compare("/companyzip")||
0==argv[argvi+0].compare("/CompanyZip")||
0==argv[argvi+0].compare("/COMPANYZIP")||
0==argv[argvi+0].compare("/companyzipcode")||
0==argv[argvi+0].compare("/CompanyZipcode")||
0==argv[argvi+0].compare("/CompanyZipCode")||
0==argv[argvi+0].compare("/COMPANYZIPCODE")
)) {
//record_update(argv[argvi+1].c_str(),
argv[argvi+2].c_str());
//return 0;
switch(commandState) {
case PHONELIST_CMD_UPDATE:
case PHONELIST_CMD_INSERT:
updateargs.has_companypostalcode=true;
strcpy(updateargs.companypostalcode,
argv[argvi+1].c_str());
break;
case PHONELIST_CMD_SEARCH:
case PHONELIST_CMD_EXPORTCSV:
case PHONELIST_CMD_EXPORTTXT:
case PHONELIST_CMD_EXPORTEXCELXML:
searchargs.has_companypostalcode=true;
strcpy(searchargs.companypostalcode,
argv[argvi+1].c_str());
break;
case PHONELIST_CMD_DELETE:
printf("ERROR: SHOULD NOT RECEIVE ARGS AFTER
-delete
COMMAND\n");
help();
return 1;
default:
printf("ERROR: SHOULD NOT RECEIVE ARGS WITHOUT
COMMAND\n");
help();
return 1;
}
argc--;argvi++;
argc--;argvi++;
continue;
}
else if (argc>=2 && (
0==argv[argvi+0].compare("--companycountry")||
0==argv[argvi+0].compare("--CompanyCountry")||
0==argv[argvi+0].compare("--COMPANYCOUNTRY")||
0==argv[argvi+0].compare("-companycountry")||
0==argv[argvi+0].compare("-CompanyCountry")||
0==argv[argvi+0].compare("-COMPANYCOUNTRY")||
0==argv[argvi+0].compare("/companycountry")||
0==argv[argvi+0].compare("/CompanyCountry")||
0==argv[argvi+0].compare("/COMPANYCOUNTRY")
)) {
//record_update(argv[argvi+1].c_str(),
argv[argvi+2].c_str());
//return 0;
switch(commandState) {
case PHONELIST_CMD_UPDATE:
case PHONELIST_CMD_INSERT:
updateargs.has_companycountry=true;
strcpy(updateargs.companycountry,
argv[argvi+1].c_str());
break;
case PHONELIST_CMD_SEARCH:
case PHONELIST_CMD_EXPORTCSV:
case PHONELIST_CMD_EXPORTTXT:
case PHONELIST_CMD_EXPORTEXCELXML:
searchargs.has_companycountry=true;
strcpy(searchargs.companycountry,
argv[argvi+1].c_str());
break;
case PHONELIST_CMD_DELETE:
printf("ERROR: SHOULD NOT RECEIVE ARGS AFTER
-delete
COMMAND\n");
help();
return 1;
default:
printf("ERROR: SHOULD NOT RECEIVE ARGS WITHOUT
COMMAND\n");
help();
return 1;
}
argc--;argvi++;
argc--;argvi++;
continue;
}
-------------
Jim Michaels
[email protected]
[email protected]
http://JimsComputerRepairandWebDesign.com
http://JesusnJim.com (my personal site, has software)
http://DoLifeComputers.JesusnJim.com (group which I lead)
---
Computer memory/disk size measurements:
[KB KiB] [MB MiB] [GB GiB] [TB TiB]
[10^3B=1,000B=1KB][2^10B=1,024B=1KiB]
[10^6B=1,000,000B=1MB][2^20B=1,048,576B=1MiB]
[10^9B=1,000,000,000B=1GB][2^30B=1,073,741,824B=1GiB]
[10^12B=1,000,000,000,000B=1TB][2^40B=1,099,511,627,776B=1TiB]
Note: disk size is measured in MB, GB, or TB, not in MiB, GiB, or TiB.
computer
memory (RAM) is measured in MiB and GiB.
________________________________
From: James K Beard <[email protected]>
To: Jim Michaels <[email protected]>; [email protected]
Sent: Sun, March 27, 2011 11:19:20 PM
Subject: RE: [Mingw-w64-public] sezero 4.5.2 1002 note: variable tracking size
limit exceeded with -fvar-tracking-assignments, retrying without
Jim: Please forgive me if I am being impractical here, but perhaps I’m missing
something. From your post it seems that you could reduce the size of your main
program by using an external function or module that does case-insensitive
string comparisons. A cycle-count purist would object to the exercise of the
call stack but in practice you would not see a perceptible change in speed for
the user.
Another red flag is that you are putting everything in main(), a practice that
has been discouraged in every computer science primer that I have seen because
of maintainability. You have most of a 10,000 LOC application in a single main
module. My personal solution when I find any module getting two big is to
block
it out in separate functions or operations, then break out those as procedures
or modules and replace my big module with a list of calls and loops so that its
function becomes control, with most or all processing moved out to called
procedures or modules. From your short description of the code, one
possibility
is breaking out each set of switches as a separate module.
James K Beard
From:Jim Michaels [mailto:[email protected]]
Sent: Monday, March 28, 2011 1:26 AM
To: [email protected]
Subject: Re: [Mingw-w64-public] sezero 4.5.2 1002 note: variable tracking size
limit exceeded with -fvar-tracking-assignments, retrying without
if it helps any, this means "out of memory". the code is 10,000 loc (lines of
code) and main is about probably 7000 lines worth of switches and lots of
strings.
I really don't know how to code this without using a huge main(). the code is
different for each if statement, there are between 4-40 string comparisons
each,
and class manipulations.
Just ask and I can attach the code or post a URL to it with a build system in
place.
it's the file phonelist.cpp and guibackend.cpp, neither one will compile and
they ar3e both similar in this respect.
I am forced to use a WinMain() because they use DLL's, so I think I have to use
the -mwindows switch.
I am unable to use the sezero 4.5.2 1002 personal build. I don't know what
build I can use, I may just try the TDM just to see if it makes any difference
(doesn't sound like it, because the problem I am running into has nothing to do
with inlines, I have no inlines in that code).
I would greatly appreciate any help someone could give me. this code used to
build until I added20-30 new fields, and thus a at least 4-6x more new switches.
the code would be GREATLY reduced if Bjarne Stroustrup (or someone) would fix
the Standard C++ Library (STL) to include a case-insensitive set of compares
for
the string template (#include <string>). If someone could do that with gcc or
especially with the standard I think everyone would be really happy. it would
reduce coding by about 6x and reduce code breakage. because right now, my code
won't compile due to sheer size I think.
My System (I hope to upgrade soon to 24GB RAM System which I desperately need):
XP Pro Sp3 32-bit, 3GB RAM, 2TB hard disk
C:\prj\phonelist\pg-phonelist-3.3>\u\df -a
*C:-----------------*********************** 1.18TB/ 2.00TB (59.14%)
TOT:-----------------*********************** 1.18TB/ 2.00TB (59.14%)
TOT USED: ------------------------**************** 817.44GB/ 2.00TB (40.86%)
C:\prj\phonelist\pg-phonelist-3.3>
________________________________
From:Jim Michaels <[email protected]>
To: mingw64 <[email protected]>
Sent: Fri, March 25, 2011 9:57:40 PM
Subject: [Mingw-w64-public] sezero 4.5.2 1002 note: variable tracking size
limit
exceeded with -fvar-tracking-assignments, retrying without
C:\prj\phonelist\pg-phonelist-3.3>rem
c:\mingw-w32-bin_i686-mingw_20101002_4.5_sezero\mingw32\bin\g++.exe -Wall -W -O
-mwindows -g -static-libgcc -isystem /l
ibpq/ -isystem /libpq/server/libpq/ -isystem /prj/fltk/fltk-1.1.10/ -isystem
/prj/fltk/fltk-1.1.10/lib/ -isystem /prj/zlib-1.2.5/
-I/libpq/;/libpq/server/libpq/
;/prj/fltk/fltk-1.1.10/;/prj/zlib-1.2.5/
-L/libpq/;/libpq/server/libpq/;/prj/fltk/fltk-1.1.10/lib/;/prj/zlib-1.2.5/
-std=c++0x -o phonelist.exe phonelist.cpp s
tring2.cpp
atoi64.cpp
phonelist.manifest.res
c:\mingw-w32-bin_i686-mingw_20101002_4.5_sezero\mingw32\lib\gcc\i686-w64-mingw32\4.5.2\libgcc.a
c:\mingw-w32-bin_i686-mingw_20101002_4.5_sezero\mingw32\lib32\li
bstdc++.a 2> errgw
C:\prj\phonelist\pg-phonelist-3.3>c:\mingw-w32-bin_i686-mingw_20101002_4.5_sezero\mingw32\bin\g++.exe
-Wall -W -O -mwindows -g -static-libgcc -isystem /libpq
/ -isystem /libpq/server/libpq/ -isystem /prj/fltk/fltk-1.1.10/ -isystem
/prj/fltk/fltk-1.1.10/lib/ -isystem /prj/zlib-1.2.5/ -std=c++0x -o
phonelist.exe phone
list.cpp string2.cpp
atoi64.cpp
phonelist.man
ifest.res
c:\mingw-w32-bin_i686-mingw_20101002_4.5_sezero\mingw32\lib\gcc\i686-w64-mingw32\4.5.2\libgcc.a
c:\mingw-w32-bin_i686-mingw_20101002_4.5_sezero\mingw3
2\lib32\libstdc++.a 2>errgw
C:\prj\phonelist\pg-phonelist-3.3>type errgw
phonelist.cpp: In function 'bool do_insert(CRecord&)':
phonelist.cpp:1927:28: warning: unused variable 'st'
phonelist.cpp:1928:17: warning: unused variable 'ntuples'
phonelist.cpp:1930:17: warning: unused variable 'index'
phonelist.cpp:1931:18: warning: unused variable 'isNotGlobal'
phonelist.cpp: In function 'bool do_search(CRecord&)':
phonelist.cpp:2927:28: warning: unused variable 'st'
phonelist.cpp: In function 'bool do_importcsv()':
phonelist.cpp:3369:28: warning: unused variable 'st'
phonelist.cpp:3370:17: warning: unused variable 'ntuples'
phonelist.cpp:3372:17: warning: unused variable 'index'
phonelist.cpp: In function 'bool do_exportcsv(CRecord&)':
phonelist.cpp:4182:22: warning: statement has no effect
phonelist.cpp:4045:28: warning: unused variable 'st'
phonelist.cpp: In function 'bool do_exportxml(CRecord&)':
phonelist.cpp:4755:28: warning: unused variable 'st'
phonelist.cpp: In function 'bool do_importtxt()':
phonelist.cpp:5469:28: warning: unused variable 'st'
phonelist.cpp:5470:17: warning: unused variable 'ntuples'
phonelist.cpp:5472:17: warning: unused variable 'index'
phonelist.cpp:5475:18: warning: unused variable 'isNotGlobal'
phonelist.cpp: In function 'bool do_exporttxt(CRecord&)':
phonelist.cpp:6413:28: warning: unused variable 'st'
phonelist.cpp: In function 'void ParseCommandLine(CHAR*, int&,
std::vector<std::basic_string<char> >&)':
phonelist.cpp:7066:35: warning: comparison between signed and unsigned integer
expressions
phonelist.cpp: In function 'int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*,
int)':
phonelist.cpp:7112:9: warning: unused variable 'eindex'
phonelist.cpp: At global scope:
phonelist.cpp:7102:12: warning: unused parameter 'hInstance'
phonelist.cpp:7102:12: warning: unused parameter 'hPrevInstance'
phonelist.cpp:7102:12: warning: unused parameter 'nCmdShow'
phonelist.cpp: In function 'int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*,
int)':
phonelist.cpp:7102:12: note: variable tracking size limit exceeded with
-fvar-tracking-assignments, retrying without
string2.cpp: In function 'int _strnicmp(char*, char*, int)':
string2.cpp:69:12: warning: unused variable 'ch1'
string2.cpp:69:17: warning: unused variable 'ch2'
atoi64.cpp: In function 'uint64_t atou64_(const char*)':
atoi64.cpp:758:33: warning: comparison between signed and unsigned integer
expressions
atoi64.cpp:772:33: warning: comparison between signed and unsigned integer
expressions
atoi64.cpp:786:33: warning: comparison between signed and unsigned integer
expressions
atoi64.cpp:800:33: warning: comparison between signed and unsigned integer
expressions
C:\prj\phonelist\pg-phonelist-3.3>dir phonelist.exe
Volume in drive C is samsung 2000
Volume Serial Number is 783C-0FA9
Directory of C:\prj\phonelist\pg-phonelist-3.3
03/25/2011 09:47 PM 1,584,660 phonelist.exe
6 File(s) 237,991,942 bytes
0 Dir(s) 1,173,900,255,232 bytes free
C:\prj\phonelist\pg-phonelist-3.3>
-------------
Jim Michaels
[email protected]
[email protected]
http://JimsComputerRepairandWebDesign.com
http://JesusnJim.com (my personal site, has software)
http://DoLifeComputers.JesusnJim.com (group which I lead)
---
Computer memory/disk size measurements:
[KB KiB] [MB MiB] [GB GiB] [TB TiB]
[10^3B=1,000B=1KB][2^10B=1,024B=1KiB]
[10^6B=1,000,000B=1MB][2^20B=1,048,576B=1MiB]
[10^9B=1,000,000,000B=1GB][2^30B=1,073,741,824B=1GiB]
[10^12B=1,000,000,000,000B=1TB][2^40B=1,099,511,627,776B=1TiB]
Note: disk size is measured in MB, GB, or TB, not in MiB, GiB, or TiB.
computer
memory (RAM) is measured in MiB and GiB.------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public