473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VC7.1 "__forceinline" 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 1772
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
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,...
5
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...
226
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...
10
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...
29
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...
2
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
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...
17
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...
244
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
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.