In my new developed Visual C++ 6 project I derived about 4 new classes based upon CDialog base class. In later stage I required to add a greate number of CString type variables. (the line numbers exceeded 4600) When I declared them in a existing Class header file, it seems the the compiler limit exceeded. Could not compile with 2 or 3 standard limite completes. Then I created a new header file through 'project insert - header file', with #def MYHEADER.H, also tried #ifndef cplusplus #def etc. Put all new variable declaration in that file. But compiler halts at "Generating Code". I worked further, splitted declarations is small header files. I tried #pragma pack(n). But all is halted. Could somebody solve this problem.
Basic problem solving
Collapse
X
-
First, you do not declare variables in a header file.
Header files are to contain only declarations and not definitions.
A declaration says a thing exists.
A definition creates it.
Variables in header files are usually global variables. If so, there is a limit to global memory in a program. That can cause a program with a lot of globals tto not build.
Variables in header files are created each time the header is included. This can cause the linker to fail when there are many variables with the same name in the same scope.
Variables declared in functions as local variables go into the functions stack frame. Here again, there may ne limits to stack memory that will crash your program at run time.
You need to:
1) remove all variables from your header files.
2) allocate your 4600 CStrings yourself using the new operator. That will put the strings on the heap where there is effectively no size limit.
3) you delete the strings when you are finished with them.
This will let you pass the strings around by pointer or reference. -
Originally posted by JosAH1s/declare/define/Comment
-
Originally posted by weaknessforcatsDang! I mean't define. I was thinking define. But you only declare in a header file so that's what I typed. Geez!
for themselves ;-)
kind regards,
JosComment
-
Originally posted by JosAHdexter sapiens syndrome
(Problem Exists Between Chair And Keyboard).
I must admit dexter sapiens is far more cultured and rolls off the tongue with flavors of erudition.
PEBCAK is more like HOCK-A-PAT-TOO-EE.
Must be a Saxon/Norman thing still lingering from 1066.Comment
-
Originally posted by weaknessforcatsWindows folks call that a PEBCAK error.
(Problem Exists Between Chair And Keyboard).
I must admit dexter sapiens is far more cultured and rolls off the tongue with flavors of erudition.
PEBCAK is more like HOCK-A-PAT-TOO-EE.
Must be a Saxon/Norman thing still lingering from 1066.
Exists Between Brains And FIngers thingie; your brains want your fingers to
type, say, "main" and your fingers go "make"; little rascals they are. You
want to type "integral" and your fingers go "int i;" all by themselves.
It's got nothing to do with chairs, nor with the battle of Hastings; it's just those
bloody fingers that think they know better ;-)
kind register,
Jav^H^Hove^H^H< stop it!>syste^H^H^H ^H<cut that out!> ;-)Comment
-
Thank you JosAH. I came from the C world. Since DOS vanished I turned to this VB. Since it seem limitations I entered at VC++ 6. All where I learned to declare variables in header files (except vb) for globals sake. Things are not so straight forward to operate with 'new' and 'delete'. Your suggestion is under thinking process. But it would be glad if the things were as thought.Comment
-
Originally posted by mampThank you JosAH. I came from the C world. Since DOS vanished I turned to this VB. Since it seem limitations I entered at VC++ 6. All where I learned to declare variables in header files (except vb) for globals sake. Things are not so straight forward to operate with 'new' and 'delete'. Your suggestion is under thinking process. But it would be glad if the things were as thought.
delete operators you can think of malloc and free for simplicity; the objects
your create and destroy that way are the dynamic objects in your program.
the 'new' operator invokes one of your constructors in your class and the delete
operator invokes the destructor of your class.
kind regards,
JosComment
Comment