473,804 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VC7.1 "__forceinl ine" not as good as VC6?

We've been using VC6 for some time and are trying to port some specific
code to VC7.1 (VC++ .Net 2003). But I've come across problems where
__forceinline doesn't inline simple inline assembly that we need to be
inlined. VC6 has no such problems.

A simple, stripped-down, example is as follows:

__forceinline void func()
{
__asm
{
push offset _end
ret
_end:
}
}

It seems to be the "push offset _end" that's causing the problem. When
this is included, I get the following "warning C4714: function 'void
func ()' marked as __forceinline not inlined".

I've seen this in VC6 where certain mnemonics prevent inlining, and
changing these to use _emit fixes this, but I don't think _emit can be
used in the above example since the compiler needs to know the address
of "_end".

I've tried various compiler switches but nothing seems to be helping. My
only current solution is to build .libs in VC6 for the critical code and
use VC7 for the rest, but this isn't really a long-term solution.

Maybe there's a hidden option or #pragma somewhere to improve the
functionality of __forceinline?

Any ideas?

Nov 17 '05 #1
2 1794
JC [Mon, 05 Apr 2004 14:01:38 +0100]:
changing these to use _emit fixes this, but I don't think _emit can be
used in the above example since the compiler needs to know the address
of "_end".


I don't think the x86 gives direct access to the pc (program
counter, whatever it's called in x86) so those of us that
did this sort of stuff used a trick like this:

call me
me: pop eax ; eax->$

and pop it from the stack. Bound to mess up the call/return
stack (as far as internal CPU optimization goes) but if you
know better go for it. Of course you'd have to add a few
bytes to get to the location you wanted (_end), but that
should work.

--
40th Floor - Software @ http://40th.com/
iPlay : the ultimate audio player for iPAQs

Nov 17 '05 #2
he*@40th.com wrote:
I don't think the x86 gives direct access to the pc (program
counter, whatever it's called in x86) so those of us that
did this sort of stuff used a trick like this:

call me
me: pop eax ; eax->$

and pop it from the stack. Bound to mess up the call/return
stack (as far as internal CPU optimization goes) but if you
know better go for it. Of course you'd have to add a few
bytes to get to the location you wanted (_end), but that
should work.


You are correct, you can't access EIP (instruction pointer) directly in x86.

I am aware of the trick you suggest, but had used "push offset label" in
preference to avoid manual calculations of the offsets. But when using
this idea, my simple test code does now inline OK. I have lots of more
complex code to modify and test but hopefully this can be done an
everything will inline.

Still doesn't explain why VC.Net doesn't do this as well as VC6, maybe
it thinks it knows better?

Many thanks for the idea.

Nov 17 '05 #3

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

Similar topics

24
3619
by: matty | last post by:
Go away for a few days and you miss it all... A few opinions... Programming is a craft more than an art (software engineering, not black magic) and as such, is about writing code that works, first and foremost. If it works well, even better. The same goes for ease of maintenance, memory footprint, speed, etc, etc. Most of the time, people are writing code for a use in the *real world*, and not just as an academic exercise. Look at...
5
2054
by: AaronV | last post by:
Hello, I'm a webmaster for a college newspaper and I'm implementing an article search. I'm running PHP with a MySQL database to store the weekly stories. Does anyone know of an article that could offer good search theory. My top priority right now is multiple search terms and relevance sorting based on how many word hits are returned.
226
12735
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d1 = {'a':1} >>> d2 = {'b':2} >>> d3 = {'c':3}
10
2035
by: KN | last post by:
I know both are pretty much the same and it comes down to personal choice. But I have to make the choice for the team. Things so far that I am considering 1. XML documentation in C# -- thats good.. not there in VB.net?? 2. Some language features of VB.Net like Redim(makes it easier for developers), but not good enough reason. 3. C# is in more like standard languages and key words used are more
29
3034
by: RAY | last post by:
Hi , my boss has asked I sit in on an interview this afternoon and that I create some interview questions on the person's experience. What is C++ used for and why would a company benefit from someone who could use it? I would like you guys/and gals to give me some good questions & the correct answers so I can give this person a good review for my boss.
2
1527
by: mit | last post by:
i want to be a good c++ programmer what i have to do.can any bod (professional ) help?? Mit
113
12362
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same algorithm work with strings that may or may not be unicode 3) Number of bytes back must either be <= number of _TCHARs in * sizeof(_TCHAR), or the relation between output size and input size can be calculated simply. Has to take into account the...
17
14686
by: Brett | last post by:
I'd like references on where to find some good (quality) icons to use for form and application icons (for the EXE). Most of the free stuff isn't that great looking and there isn't a good selection. A site offering previews of icons or purchase of a single icon would be nice. Thanks, Brett
244
9632
by: Ajinkya | last post by:
Can anyone suggest me a good compiler for(c/cpp) for windows? I tried dev cpp but its debugging facility is very poor.
76
4100
by: lorlarz | last post by:
Crockford's JavaScript, The Good Parts (a book review). This shall perhaps be the world's shortest book review (for one of the world's shortests books). I like Douglas Crockford (because I am a crabby old man too; plus he _is_ smart and good).. But, how can he write a book on the good parts of JavaScript and not mention functions that address CSS & DOM? Weird. It's like
0
9708
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
10340
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
10324
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
10085
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
9161
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...
1
7623
isladogs
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...
0
6857
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();...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2998
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.