473,394 Members | 1,774 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,394 software developers and data experts.

debug vs release version

105 100+
Hi all,

I have some theoritical questions.

1. Why sometimes any piece of code works fine in th debug version and fails in the release version ?

could anyone please state the difference between relase and debug version?

2. int *ptr[10]; //10 pointers pointing to an integer

what happens if we do ptr++ ?What should I do if I want to acess all the pointers?

int(*ptr)[10]; //pointer pointing to an array of integers
what happenes if we do ptr++ here ?Can I do it?

Need little bit explanation about it.

Thanks
Jun 19 '08 #1
5 1842
1. No clue. I guess you're talking about Visual C++. No clue anyway

2. It will increment the pointer the memory positions that take an int. In the particular case of a 32-bit int, it will increase the memory position in 4.

3. It will increment the pointer the memory positions that take 10 ints. In the case of 32-bit int's, it will increase it 40 positions.

Why? because the "++" operator on pointers increments the address the number of bytes of the pointed type.
Jun 19 '08 #2
pootle
68
In answer to 1, the most common reason is because the timing changes between the two. The debug build includes loads of checks that slows it down a lot.

Regards
Jun 19 '08 #3
mickey22
105 100+
Thank you for the reply.

ptr++ in the second case increases by 40 ----- does it mean that ptr++ means it points to the last element of the array it is pointing to?
If I want to acess some middle element how do I call through this pointer.

For eg: a[]={1,2 ,3,4};
int (*ptr)[4];

if I want to print out a[2]=3 using *ptr how can i do it?
Jun 19 '08 #4
ptr++ in the second case increases by 40 ----- does it mean that ptr++ means it points to the last element of the array it is pointing to?
Not the last, but the next.

e.g.:

ptr points to the first position

ptr++ -> will get it to point to the next one

If I want to acess some middle element how do I call through this pointer.

For eg: a[]={1,2 ,3,4};
int (*ptr)[4];

if I want to print out a[2]=3 using *ptr how can i do it?
first you have to get one of the four pointers in (*ptr)[4] to point to a[], you can do it like:

Expand|Select|Wrap|Line Numbers
  1. ptr[0] = a;
(in this case you take ptr[0]).

Afterwards, you can access a[2] by accessing either a[2] or ptr[0][2].
Jun 19 '08 #5
Banfa
9,065 Expert Mod 8TB
1. Why sometimes any piece of code works fine in th debug version and fails in the release version ?

could anyone please state the difference between relase and debug version?
Debug code contains all the information that the symbolic debugger requires to locate the symbols in memory. Also it is normal to switch off the optimiser when producing a debug build otherwise it can be very hard to follow the code through the debugger. The debug build is often many times bigger than the release build.

As has been mentioned time issues can occur in debug builds because of the increase code size but there can be other effects too. An old version of the Microsoft compiler used to initialise automatic variables to 0 in the debug build. This meant that if you forgot to initialise a variable you could create a working debug build and a non-working release build.

2. int *ptr[10]; //10 pointers pointing to an integer

what happens if we do ptr++ ?What should I do if I want to acess all the pointers?

int(*ptr)[10]; //pointer pointing to an array of integers
what happenes if we do ptr++ here ?Can I do it?
In your first case
Expand|Select|Wrap|Line Numbers
  1. int *ptr[10];
  2. ptr++;
the code is not compilable because ptr is not an l-value because in fact ptr is not a pointer, it is an array. Because of this the ++ operator is not valid for it.

In the second case
Expand|Select|Wrap|Line Numbers
  1. int (*ptr)[10];
  2. ptr++;
as stated already ptr++ increments the address pointed to by sizeof(*ptr). I would recomend you google for pointer arithmetic, there are many pages explaining it.
Jun 19 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Raphael Zulliger | last post by:
Hi I have to check wheter a .py script is run within the debug or the release version of an embedded python interpreter (in short, wheter python24_d.dll or python24.dll is in use). long...
6
by: ss | last post by:
Hi I built an exe in console debug mode & Release mode . The console debug mode -exe works fine ...but the release mode EXE starts well but fails mid way . The exe is being started as a...
5
by: David Krmpotic | last post by:
it's me again.. with quite interesting discovery :) I was tracing an error for 3 hours instead of 3 minutes because of this surprise. Recently I'm compiling this project in RELEASE with Debug...
5
by: David++ | last post by:
Hi there, I have built a DLL in Visual C++ 6. When I build the DLL it builds fine for the debug version of the DLL (and this DLL works fine), however, I seem unable to build a Release version of...
9
by: dee | last post by:
Hi I'm about to upload my site and I have switched to release version. Is that enough or do I still need to disable <compilation defaultLanguage="vb" debug="true" /> the debug="true" in the .pdb...
3
by: | last post by:
Since I need to dotfuscate my exe file anyway, does it make any difference if I use Debug or Release versions. Would a Debug version be easier to decompile/study/reverse engineer than a Release...
1
by: mike2036 | last post by:
I have a very strange problem trying to link the debug version of my caller application with one of my DLL's using .NET 2K5. The linker declares the following error (one of many): error...
2
by: Epetruk | last post by:
Hello, I have a problem where an application I am working on throws an OutOfMemoryException when I run it in Release mode, whereas it doesn't do this when I am running in Debug. The...
6
by: Andrew Rowley | last post by:
I am having trouble getting debug and release builds to work properly with project references using C++ .NET and Visual Studio 2003. I created a test solution, with a basic Windows form C++...
3
by: TBass | last post by:
Hello, Is there a way to get Visual Studio 2003 look to one directory for debug version dlls when set to DEBUG and then to another directory where I store the release version of a dll when set...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
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...

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.