473,785 Members | 2,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Large Object within Pointer to Function & Switch

Do you know that current C++ Compiler limits to 64KB segments in source
code? It is good news that Microsoft Visual C++ 2005 has expanded to 4GB
segments in source code. 4GB segment is ideal for large object using
pointer to function and switch. Please list other C++ Compilers if they
have added a support of 4GB segments.
I am able to write 65,536 functions and 65,536 function's memory address
is stored into pointer to function list. It takes about 256KB. The test
has shown that each function out of 65,536 functions have been executed
successfully with correct result in both debug version and release version.
Switch can contain 65,536 cases in debug version, but C++ Compiler takes
more time to compile than pointer to function. Unfortunately, it will not
compile in release version. Unknown error is not found in any
documentation. (Not important to discuss this issue.)
I think that it is best practice to write small functions through
pointer to function list rather than large switch in one big function. By
the way, small functions can fit in cache. (Correct?).
If you are going to write 1 to 268,435,456 functions, memory address in
pointer to function list will take up to 1GB.
I know what you are going to say -- laugh -- can't be done. I urge you
to try if you are willing to write complex project. Think about holographic
character like Star Trek or character for game what you want to write. This
big object contains body including head, arm, leg, and everything. You need
to write hundred or thousand functions to respond moving arm, leg, and head.
More functions to be responded for mouth talking.
It makes 32-bit CPU machine to be slower to manipulate C++ Compiler for
large object so 64 bit CPU machine may be working with large RAM.

Please tell me what you think the best practice. Live with big object
by adding /bigobj and /Gy to Microsoft C++ Compiler. Check option
documentation for other C++ Compilers. Should write large pointer to
function list in more than 1 million line of source code? Or...Split half
or quarter function to pointer list into two or four module source code?

Please refer me to other newsgroups when I am interested to work large
object using optimization and performance using C++ Compiler's option, but
not through Microsoft alone. Please advise.

Bryan Parkoff
Oct 28 '06
14 1959

Bryan Parkoff wrote in message ...

Huh?

http://www.parashift.com/c++-faq-lite/how-to-post.html

Oct 29 '06 #11
Bryan Parkoff <no****@nospam. comreplies to my post,
>How are you guys defining "segment"?
>Steve,
Sorry. My mistake. I refer section (not segment). Look
this article below.

Microsoft Article: [snip]
Thanks, that's very interesting. Apparently it's some limitation
on resolving function calls in the linker.

(I wouldn't think it'd be too much trouble for an implementation
to remove this limit entirely, but I've seen stranger limitations.)

Steve
Oct 29 '06 #12

"BobR" <Re***********@ worldnet.att.ne twrote in message
news:cb******** *************@b gtnsc05-news.ops.worldn et.att.net...
>
Bryan Parkoff wrote in message ...

Huh?

http://www.parashift.com/c++-faq-lite/how-to-post.html
Well,

I did follow guideline, but I ask people to rephrase their opinion. My
question is -- is it best practice to write 64K functions or more into
pointer to function list? Is it best to create small or big function? It
is simple question. It seems that none wish to answer this question. They
may feel sorry when they face problem near the future so they will ask the
same question since in the past.
I have researched to get more information how C++ Compiler can handle
the limitation for general OS, but none implement to provide good
documentation nor FAQs. I do see when they claim to be 1,024 maximum for
functions. However you should be able to exceed limit and perform test to
prove that it is working perfectly. Didn't you?

Bryan Parkoff
Oct 29 '06 #13

Bryan Parkoff wrote:
"BobR" <Re***********@ worldnet.att.ne twrote in message
news:cb******** *************@b gtnsc05-news.ops.worldn et.att.net...

Bryan Parkoff wrote in message ...

Huh?

http://www.parashift.com/c++-faq-lite/how-to-post.html

Well,

I did follow guideline, but I ask people to rephrase their opinion. My
question is -- is it best practice to write 64K functions or more into
pointer to function list? Is it best to create small or big function? It
is simple question. It seems that none wish to answer this question. They
may feel sorry when they face problem near the future so they will ask the
same question since in the past.
I have researched to get more information how C++ Compiler can handle
the limitation for general OS, but none implement to provide good
documentation nor FAQs. I do see when they claim to be 1,024 maximum for
functions. However you should be able to exceed limit and perform test to
prove that it is working perfectly. Didn't you?
Maybe it's because we don't understand the question. I'm certainly
finding it difficult to understand.

Are you asking about objects as instances of classes or objects as in
object files, the results of compilation? The subject line seems to
imply the first, the content the second.

Why would you want a switch statement that had 65,535 cases in it? Why
would you want to write your own message dispatcher like this?

When you say "64K functions" your talking about the number of
functions? I find it hard to imagine that anybody would write that many
functions even on a huge system and expect them all to be called
through a single switch statement. If you find that you want to do this
then I suspect you'd be better off thinking about redesigning your
solution rather than worrying about compiler limits.

Function size is a tricky one. Functions should be the right size, and
normally the right size is small, but of course there are many
exceptions and edge cases where to split a function just becomes
arbitrary. Personally I always go for the easiest to maintain size, and
not worry too much about how the compiler will aggregate
up/inline/unroll functions unless I've proven that there isn't a better
algorithm I can use to speed things up. Finding a better method
generally gives much better performance boosts than worrying unduly
about function versus cache sizes.
K

Oct 29 '06 #14

Bryan Parkoff wrote in message ...
>
"BobR" wrote in message...
>Huh?
http://www.parashift.com/c++-faq-lite/how-to-post.html

Well,

I did follow guideline, but I ask people to rephrase their opinion. My
question is -- is it best practice to write 64K functions or more into
pointer to function list?
Several years ago I read a recommended paper on Unix programming. It stated
at one point "programs should do only one thing, but, do that one thing very
well". If you have hit a limit, you need to split up the task. Even the most
'function intensive' programs I've seen on GNU/Linux did not come close to
64k functions. Heck, If you look at the Linux kernel, with *everything*
turned on, it does not come close to that limit.

Is it best to create small or big function?
I came up to C++ from Assembler, so, naturally I've taken a look at the
assembler output stage of GCC. I noticed that the usual habit (necessity)
when entering a function is to do a 'pusha'(push all, x86). I thought, "that
seems excessive, in Assembler I only push-pop when and what I need". If I
*only* looked at that I would say, always put as much in one function as you
can.
But, C++ is a much stranger animal. The general advice is - do not
pre-optimise, just write clean, clear code. Then, if there is a problem with
speed, profile the program, identify the bottlenecks and only work on those
areas.

So what do I do? If I see a section of code that gets used many times, it
goes in a function(usuall y a member of a class). You should make a function
do one thing (and do it well), big or small is not the target.
It is simple question. It seems that none wish to answer this question.
You do have answers from others.

They may feel sorry when they face problem near the future so they will ask
the
>same question since in the past.
You may have problems if you spend all your time worrying about some limit,
instead of studying good design.
I have researched to get more information how C++ Compiler can handle
the limitation for general OS, but none implement to provide good
documentatio n nor FAQs.
Sounds like a personal problem, I've never seen any of the experts in these
NGs whine about some limit. (and some of them work on HUGE projects.)

I do see when they claim to be 1,024 maximum for
functions. However you should be able to exceed limit and perform test to
prove that it is working perfectly. Didn't you?
If *your* compiler can't do what you want, get a better one. www.gnu.org

MinGW (GNU compiler): http://www.mingw.org/ (windows)

Dev-C++ IDE: http://www.bloodshed.net/ (with MinGW, easy install)
MinGWStudio http://www.parinyasoft.com/
--
Bob R
POVrookie
Oct 29 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1780
by: Patrick | last post by:
I want to achieve the following behaviour but I am having trouble getting there...bare with me im knew to c++ , so its probably rather trivial! To have a class ClassA, and composed within this class is an instance of another class, ClassB. I want to have a method getClassB that returns a reference to the instance of ClassB composed within ClassA. So when a client calls getClassB they are supplied with a reference to the instance of...
6
3710
by: Ian Robertson | last post by:
I am trying to write a function that takes a reference to an object as its arguement. The object is created in another function and I am trying to pass the object to another function from within the function that created the object. I have cut out some code as I dont think showing a for loop is helpful. void TMP3_Main_Form::LoadMP3() { TMemoryStream *MP3Stream = new TMemoryStream();...
35
3053
by: Frederick Gotham | last post by:
(Before I begin, please don't suggest to me to use "std::vector" rather than actual arrays.) I understand that an object can have resources (e.g. dynamically allocated memory), and so we have to copy an object properly via copy- construction rather than using memcpy. However, is it okay to move an object manually (i.e. by using memcpy or memmove)?
20
4285
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site is structured as an upside-down tree, and (if I remember correctly) never more than 4 levels. The site basically grew (like the creeping black blob) ... all the pages were created in Notepad over the last
14
2582
by: Jeroen | last post by:
Hi all, I've got a question about writing a library. Let me characterize that library by the following: * there is a class A which is available to the user * there is a class B that is used in severel 'underwater operations' * there is a list which stores objects of class B There are several issues I'm not sure about:
9
5015
by: grbgooglefan | last post by:
I am trying to pass a C++ object to Python function. This Python function then calls another C++ function which then uses this C++ object to call methods of that object's class. I tried something like this, but it did not work, gave core dump. class myclass { public: myclass(){}; ~myclass(){};
10
2051
by: sumsin | last post by:
The C++ Object Model book says that 'Nonstatic data members are allocated directly within each class object. Static data members are stored outside the individual class object. Static and nonstatic function members are also hoisted outside the class object. Virtual functions are supported in two steps: A table of pointers to virtual functions is generated for each class (this is called the virtual table). A single pointer to the...
3
3343
by: Giovanni Gherdovich | last post by:
Hello, in the following code I have a pointer (to function), say p, of type double (*)(double, double, void*) and I try to fix the second argument of the function *p to a given value (using boost::bind), but the compiler complains, because of a type mismatch in an assignment which I think should be legal:
2
4309
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the file. The portion that is not working is the star rating part <?php session_start(); include_once('includes/host_conf.php'); include_once('includes/db_connect.php'); include_once('includes/mysql.lib.php');...
0
9645
marktang
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...
0
10330
Oralloy
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...
0
10153
jinu1996
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...
1
10093
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,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
agi2029
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...
0
5381
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...
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.