How can i disable in Atmel Studio the compiler optimization? - atmelstudio

I have a problem when i'm using static functions because after rebuild/build the compiler does not generate the object code of this functions ( i see that because assembler code of this functions is not generated in .lss file ). How can i disable compiler optimization to avoid this issue.

Apparently the link above is broken/no longer pointing to the document. To help others (and my future self):
Disable Optimization in Atmel Studio / Microchip Studio:
Open the properties for the current project (Alt-F7) or Project >
(PrjName) Properties
Select the Toolchain menu from the left side:
AVR/GNU C Compiler > Optimization
For Optimization Level, set to None (-O0)

Please see the following link.
https://www.microchip.com/webdoc/GUID-ECD8A826-B1DA-44FC-BE0B-5A53418A47BD/index.html?GUID-9241847D-2474-41F8-86D0-BD8BCD80BC8E
Under the Toolchain settings of the current project you can select the optimization via a simple drop-down list.

Related

C++ Builder (XE7) compile without linking?

Is it possible - only compile/make source in C++ Builder (XE7) without the long delay of linking?
If yes, is there a shortcut key for it?
It would be very useful when I just want to check if my code compiles at a point, but don't want to execute it.
mauroaraujo is right - since BCB4 or thereabouts the Project menu has an item that is misleadingly labelled 'Build ' + current source file. This compiles the current .cpp file (compiler switch -c). The item description in the documentation is a bit misleading as well.
The standard keyboard shortcut is Alt+F9 - the same as it always has been ever since the times of Turbo C/C++ (with the possible exception of some early C++Builder incarnations). The shortcut might change or disappear when certain editor key mappings are selected, though.
There seems to be no direct equivalent to 'Syntax check' item that becomes available in the Project menu when the current source is a .pas file, but for most practical purposes it should be close enough.
What the IDE doesn't seem to have is a command for compiling all sources without linking (sort of like a 'syntax check all sources'). However, you may be able to build a custom target where the link phase is configured to do nothing.

how to use protobuf-net in the xamarin ios pcl

I am trying to use protobuf-net with the new xamarin ios pcl, and it's nuget packet doesn't appear to support the framework. Is there a way to import protobuf-net into the pcl?
Update:
I just found recompiling the PCL with the new Xamarin PCL definitions allowed the resulting library to be references. Nice work! Let me know when a new version is posted to Nuget.
The NuGet package includes PCL drops, but it is unclear to me what change you would have me make to the NuGet package here, as there is no specific "Xamarin" target that I know of; the example targets are described here; protobuf-net currently includes a broad target of portable-sl4+net40+wp7+windows8. If you know of a target (or indeed a PCL build combination) that works for Xamarin for iOS, please let me know.
I should also note that the NuGet drop is the "Full" implementation, where meta-programming is performed at runtime. Because of the limitations in iOS, you may find you get better performance by using the "CoreOnly" implementation combined with the "precompile" tool, available from the google-code drop. This is described here.
I was able to use NuGet version of protobuf-net by manually editing the .csproj file for my portable library and setting the target framework profile to match protobuf-net:
<TargetFrameworkProfile>Profile136</TargetFrameworkProfile>
The resulting portable library worked well with Xamarin.Android. According to this list, it should work with Xamarin.iOS as well.

OpenCV ZXing incompatibility on iOS

I'm trying to work with ZXing and OpenCV in the same project. You wouldn't think this would be this rare of thing to do, but I guess it is. I am having some serious compatibility issues between the two. I can only get one imported without the other.
I start with OpenCV and everything works fine. Program runs as expected. Then I add ZXing, and I get about 27 compiler errors. There is a stackoverflow question that address this here. So I change my C++ compiler settings to match what this question suggests, and it fixes the ZXing problems, but then opens up a whole new set of errors. These errors are related to OpenCV now(see below).
EDIT:
It seems that depending on the C++ compiler, its a one-or-the-other type deal. In fact, if you change the c++ standard library from libc++ to libstdc++ you will get one to work and not the other. No way I can see to get both at the same time
I have found a solution to my question. This applies best to anyone using zxing and opencv in the same project.
Go to the project settings -> Target -> search for c++
a. Switch c++ Language Dialect to Compiler Default
b. Switch C++ Standard Library to libc++
Go to the ZXingWidget.xcodeproj -> ZXingWidget -> search for C++
a. Switch c++ Language Dialect to Compiler Default
b. Switch C++ Standard Library to libc++
There will be a compiler error saying that ZXing can't compile to libc++ because it's currently set to support iOS 4.3. Go into ZXing widget again, and change the deployment target to be 5.0 (sorry all of you trying to still support < 5)
This fixed my problem. Basically what was happening is that zxing and open cv were compiling on different versions of c++, which was causing some strange issues
Edit: For reference, I was using ZXing 2.1 and OpenCV 2.4.3 (Newest versions at the time of the question)
Actually, I use your solution but a little different. At step2,I change both to Complier Default, because if I use your suggestion,the error still there.So I checked the setting in ZXingWidget.xcodeproj and found that it set both Complier Default, so I changed my project setting the same as ZXingWidget.xcodeproj.
But thanks to your hint and helped me a lot!

How do I stop the debugger from stepping into Delphi-supplied units?

The debugger steps into the source code on errors (like with F7), but I want to restore the normal working mode where the Delphi basic DCUs (the library) are only compiled into my code, and the sources are not used in debugging.
For example, on an error in my program, the debugger is stepping into Controls.pas, into TControl.Click. The normal case (right after installation) is for Delphi to step over these methods.
Should I recompile Controls.pas without debug information? If so, how?
I extending this theme with additional information to better understanding:
We use Delphi6 Prof. what have problem with Mouse (System Error Code 5).
So we want to recompile to Controls.pas to replace the Mouse Position getter code.
Then:
I created a folder for it: "c:\D\Common\Delphi_Patches\Delphi_6\"
I put the original Controls.pas into it.
I modified the Controls.pas, replaced the position getter code.
I set the Delphi's Library path, set the first folder to "c:\D\Common\Delphi_Patches\Delphi_6\"
With these steps I can compiled the source with mouse-safe code.
Ok, but then the Delphi everytime steps into Controls.pas on F7, and on any exceptions - this is very "angermaker" thing.
No matter that I removed the "Controls.pas" from the Library path - then the debugger is finding the original "Controls.pas" for it, and opens it... :-(
We don't use "Use Debug DCU-s" in any codes.
I tried to remove "Debug Information" from compiler options, but it is no matter, the Delphi is opens the original Controls.pas...
So I search the way to Delphi don't step into "Controls.pas", but use my dcu...
I hope this provide better context to understand the problem.
I think that you need to Shift+Ctrl+F11 (tools/options) then in Compiler, uncheck "Use debug DCU"...Then if an exception occurs it wont break into the RTL or VCL sources.
Since you are compiling your own version of a Delphi unit, you can disable debug info in that unit. Add {$D-} to the source code of the unit(s) in question.
As I see the solution is:
create a project the uses only the new Controls.pas.
unset the "Debug information" option in compiler options.
build dcu
put the dcu into a library folder
hide the new Controls.pas from this library folders.
Wite this trick the I cannot "step into" controls.pas.
Regards: dd
I had this same problem with Delphi XE8.
You can untick the "Project >> Option >> Compiling >> Use debug .dcus" and it will continue tracing into System unit and so on.
I found that the best way to stop this is to open your Application.dproj file - which is in XML. In it, you can change the settings as follows:
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<DCC_AssertionsAtRuntime>false</DCC_AssertionsAtRuntime> <--- note false
<DCC_DebugDCUs>false</DCC_DebugDCUs>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<DCC_RemoteDebug>false</DCC_RemoteDebug>
</PropertyGroup>

Trouble disabling LLVM optimizations via pragma

I have a chunk of code that crashes unless I build with optimizations off. I'm building with LLVM compiler 2.0
I would like to turn off optimizations by wrapping the offending code with a #pragma compiler directive; or turn off optimizations for an entire file.
I've been digging in the clang manual and code; but nothing jumps out at me.
Does anyone know how to change the optimizations for a single CU (as opposed to for the entire app)?
You can set per-file compiler flags in Xcode. In Xcode 4 (which I assume you're using because of the LLVM 2.0 reference), first select the project in the left-hand project browser. Go to the Build Phases tab and expand the Compile Sources build phase.
In there, you can set per-file compiler flags, so you could try going to the offending file and entering in -O0 as a flag to try and disable optimizations for just that file.
GCC has some attributes you can set for this, as pointed out by Johannes in his answer here, but these might not be in LLVM. Also, from the comments there, it appears that these are not even in Apple's customized GCC used for building iOS applications.

Resources