Atmel Studio 6, C++ issues with unknown type "class" - atmel

I'm working with Atmel Studio 6 and am having an issue with the C++ implementation. I defined a new project, selected the C++ option and added a new class which created the class files (.cpp and .h) as expected, but when I open the .h file the "class LED" line is highlighted (an error condition) and the error says is "unknown type class"
Any ideas on what might be wrong? I have no clue.

The 'unknown type class' suggests that the compiler took 'class' as a typename, what could suggest that it took your source code as a C not C++ language.
This in turn suggests that maybe you mistook or mistyped the file extension and failed to set the name of file to .cpp. In fact, you wrote that you named the file .ccp - try correcting that first. (note the cCp versus cPp). It's quite common when you start writing in C++. Memoization hint: C++ -> CPP : the P stands for "+", "plus".

The file containing main() must also end in .cpp, but AVR Studio (6.2) creates one ending in .c. Create a new .cpp file (add - new item), move main() and all other code from the old file into the new file and delete the old one. It is not sufficient to change ending of the old one from .c to .cpp.

This is my tips:
goto Project -> [your project name] properties -> Toolchain -> AVR/GNU C++ compilers -> Directories -> add your folder that contains .cpp as relative path in Include Paths (-I) ->goto Project again -> Select 'Add existing item' -> browse to your .cpp folder -> select .cpp file -> click the down arrow in 'Add' button -> select 'Add as link'
then RECOMPILE you Projects!

Related

Premake (lua) pch create /Yc Visual Studio

In the premake lua script for my solution. How do i set it to create "/Yc" the phc instead of being set to use "/Yu" on first initialisation.
I have searched the online documentation and tried other help sites. I can't find any help.
I assume it's a build option but have tried buildoptions { "/Yc" }
Some help would be much appritiated?
The solution was to set the correct path to the source file.
premake5.lua
pchheader "awepch.h"
pchsource "%{prj.name}/Src/awepch.cpp" // this is where the source file is located on disk
* Also it is mandatory that you use the correct case for the characters. If you use "pch.h" for a file name on disk that must be the file name in this section of your "premake5.lua" script
Sorry to take so long to deliver the answer :)
you need to specify
pchheader('StdAfx.h')
and
pchsource('StdAfx.cpp')
For the current version of premake v5. 0.0-beta1, you must do the following in order for the precompiled header to work across all IDEs (especially for Visual Studio):
Put both pch.h and pch.cpp under the root directory of your project (not solution/workspace).
Set the exact name (not a path) of the pch.h to pchheader().
Set the full path of pch.cpp relative to premake5.lua script in pchsource(). This is IMPORTANT. I don't know why, but if you do not specify the full relative path, then premake will Use (/Yu) (use precompiled header) to the phc.cpp instead of Create (/Yc) (create precompiled header), which results in not creating the precompiled header in Visual Studio.
Include the directory where pch.h and pch.cpp are located in includedirs()
#include "pch.h" IN EVERY .cpp file in your project, IN THE FIRST LINE of each .cpp file. Remember: #include "pch.h", "pch.h" must be excactly the same as the string you set in pchheader() in your premake5.lua script.
If you have .c files, you MUST rename them to .cpp instead, otherwise Visual Studio will complain about using a precompiled header that was compiled using a c++ compiler.
I know it's overcomplicated but this is how it is.
Example:
project "LearnGL"
location "Projects/LearnGL/"
kind "ConsoleApp"
language "C++"
targetdir "builds/"
objdir "obj/%{prj.name}_%{cfg.shortname}"
pchheader "pch.h" --Do not use paths here. Use directly the header file name
pchsource "Projects/LearnGL/src/pch.cpp" --Full path MUST be specified relative to the premake5.lua (this) script.
files {
"Projects/LearnGL/src/**.h",
"Projects/LearnGL/src/**.hpp",
"Projects/LearnGL/src/**.cpp"
}
includedirs {
"Projects/LearnGL/src/", --This is where pch.h and pch.cpp are located.
"Projects/LearnGL/src/external/glad/include/",
"Projects/LearnGL/src/external/stb_image/include/",
"External/glfw/include/",
"External/spdlog/include/"
}

How to translate Next, Cancel, Quit Buttons ? (Qt Installer Framework based)

I would like to translate my installer wizard (Qt Installer Framework based) in English or French (OS language depends).
I added those lines in the "installscript.qs" file :
Component.prototype.retranslateUi = function()
{
component.languageChanged();
}
and I added those in "config.xml" file :
<Installer>
...
<Translations>
<Translation>fr.qm</Translation>
</Translations>
</Installer>
But everything is ok (all long texts are translated) (in French) but the buttons like "Next", "Cancel", "Quit" are not translated (see the screenshot) :
ps: I don't want to use C++ code. (only Script or Xml)
You need to load the Qt translation file in addition to your own .qm file(s). The file is located in the translation sub-folder of your Qt installation folder (e.g. ./usr/share/qt5/translations/). For some languages it seems sufficient to load qt_xx (where XX should be replaced with your locale), but for German I had to load "qtbase_XX" to translate the Next and Cancel buttons. In example for the fr locale they are named qt_fr.qm and qtbase_fr.qm.
EDIT:
Because of the comment of John Smith I checked the Installer framework source and the framework is not capable loading more than one translation file:
See installer-framework/src/libs/installer/component.cpp
/*!
Loads the translations matching the name filters \a qms inside \a directory. Only translations
with a base name matching the current locale's name are loaded. For more information, see
\l{Translating Pages}.
*/
void Component::loadTranslations(const QDir &directory, const QStringList &qms)
So my original answer above (which would lead to a translated QWizard::CancelButton) is not working.
I got the Quit button of the Installer Frameworks translation example translated to German by correcting the de.ts file provided within the framworks source in installer-framework/src/sdk/translations
The original translation coming with the feramework is missing an &:
So, changing:
<context>
<name>QInstaller::IntroductionPage</name>
...
<message>
<source>Quit</source>
<translation>Beenden</translation>
</message>
to
<context>
<name>QInstaller::IntroductionPage</name>
...
<message>
<source>&Quit</source>
<translation>Beenden</translation>
</message>
and recompiling the Framework leads to a translated Quit button (Beenden) within the framework.
I did not tried, but studying /installer-framework/src/libs/installer/packagemanagergui.cpp should enable you to translate the Next button, too.
Adding a context may help:
function Component()
{
qsTranslate("QInstaller::IntroductionPage", "&Quit");
}
It woked after Next and Back, but could not find where to write the qsTranslate().

Set default language for new files

Newly created files in Atom are always "Plain Text". How can I change this so that new files will automatically be in another language, for example "Shell Script (Bash)"? I want to do this because auto indentation does not work with Plain Text files.
Had this problem as well, there is a plugin called default-language that will do this for you.
Search atom for default-language, install and open its settings. Type the name of the language you want Atom to default to, e.g. Shell Script (if in doubt, copy from the language selection menu) in the Default Language field. Next time you open a script with no extension (or shebang) it'll default to the language you set.
The following code, added to your init.coffee, will do what you're asking:
atom.workspace.observeTextEditors (editor) ->
default_scope = 'source.shell'
original = editor.getGrammar()
# If the editor has "null" grammar (aka unset)
if original? and original is atom.grammars.grammarForScopeName('text.plain.null-grammar')
default_grammar = atom.grammars.grammarForScopeName(default_scope)
if default_grammar? # check if desired grammar is already loaded
editor.setGrammar(default_grammar)
else
# grammar was not loaded yet, so add a callback as grammars load
callback = atom.grammars.onDidAddGrammar (grammar) ->
if grammar.id is default_scope
# once we've loaded the grammar, set it and dispose of the callback
editor.setGrammar(grammar)
callback.dispose()
Things to note:
The init.coffee file is where you can customize Atom without having to write a package
The observeTextEditors method sets a callback that is called upon each TextEditor creation for currently open and future editors
The code above:
Checks the grammar that the editor was created with
If and only if it is the default ("null") grammar, it sets the editor's grammar to the Shell grammar once it's loaded
Disposes of the callback to check for grammar loading once it's done with it
This should solve the TypeError: Cannot call method 'getScore' of undefined that happens for the first file opened in a new window.
To default to a different grammar, just change the default_scope = 'source.shell' line to use the scope of whatever grammar you'd like.
Firstly, CTRL+SHIFT+L is your friend. It's unfortunately not a permanent solution, but nice to know about.
Of course, we'd prefer a more permanent solution. A couple of the other answers are now obsolete due to API changes in Atom. Below is a more up-to-date version. Inspiration initially came from this discussion, but the other answers here seem to follow the same concept as well.
Place this in your init.coffee file (File -> Open Your Init Script):
extname = require("path").extname
fileTypes =
".wxs": "text.xml"
".wxi": "text.xml"
".wixobj": "text.xml"
nullGrammar = atom.grammars.selectGrammar("text.plain.null-grammar")
atom.workspace.observeTextEditors (editor) ->
grammar = atom.grammars.selectGrammar(fileTypes[extname(editor.getPath())])
editor.setGrammar grammar if editor.getGrammar() is nullGrammar and grammar isnt nullGrammar
Basically, you define have an array of file types, and the grammars (AKA syntax highlighting) that you want to associate them with. Find each editor, find out if it has a selected grammar already, and if not, attempt to give it one if we find one.
The one issue I've had with this is that the syntax highlighting only works if you open files after you've already launched Atom; if you open a file that results in Atom launching (say by double clicking on it's icon in your favourite OS), syntax highlighting won't for that file until you re-open it.
You need to create a mapping in your config.cson file.
"*":
core:
customFileTypes:
"source.shell": [
"sh"
"shell"
]
For mapping .sh and .shell files to shell script syntax.
Have a look at this bit of code: (you can can then change 'text.html.basic' to whichever syntax you require)
editor = atom.workspace.getActiveTextEditor()
cursor = editor.getLastCursor()
valueAtCursor = atom.config.get(cursor.getScopeDescriptor(), 'my-package.my-setting')
valueForLanguage = atom.config.get(editor.getRootScopeDescriptor('text.html.basic'), 'my-package.my-setting')
For reference please see: Scope Descriptors # https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors

How can I programmatically add build files to Xcode4?

I've been trying to figure out how to programmatically add files to an Xcode4 project and it seemed like AppleScript would be the way to go, however I'm running into "missing value" errors.
Here's the code I've got:
tell application "Xcode"
set theProject to first project
set theTarget to first target of theProject
set theBuildPhase to compile sources phase of theTarget
tell first group of theProject
set theFileRef to make new file reference with properties {full path:"/Users/jeff/Projects/XcodeTest/XcodeTest/MyViewController.h", name:"MyViewController.h", path:"XcodeTest/MyViewController.h", path type:group relative}
add theFileRef to theProject
end tell
--tell theBuildPhase to make new build file with properties {build phase:theBuildPhase, name:"MyViewController.h", file reference:theFileRef, target:theTarget, project:theProject}
end tell
I've tried the commented-out line instead of the add-command as well, but that doesn't work either (I get "missing value").
The 'add' error is:
error "Xcode got an error: file reference id \"251AD3431432472E006E300F\" of Xcode 3 group id \"251AD32C14324645006E300F\" of project \"XcodeTest\" of workspace document \"XcodeTest.xcodeproj/project.xcworkspace\" doesn’t understand the add message." number -1708 from file reference id "251AD3431432472E006E300F" of Xcode 3 group id "251AD32C14324645006E300F" of project "XcodeTest" of workspace document "XcodeTest.xcodeproj/project.xcworkspace"
The "make new reference" does add the file to the list of files in Xcode, but I also need it to be added to the project target so that I can add actions and outlets to the file from Xcode w/o having to first check the checkbox to add it to the "target membership".
I ended up sending this question to the devs on the xcode developer list and the response I got was effectively "you can't".
This appears to be completely broken in Xcode4, but I've seen a project that does it. I think what they are doing is parsing and modifying the "project.pbxproj" file directly. (this file is hidden inside the xcodeproj bundle)
The file is a GUID soup, but once you look at it for a while it seems possible to safely modify it, especially if you are only adding stuff.
Edit:
Found this stackoverflow answer that might help.
Tutorial or Guide for Scripting XCode Build Phases
There is a poorly documented user defined build setting that can be added. Files can be both excluded and included from compilation
Go to your target's Build Settings > Tap the + button > Add User-Defined Setting
The key is either INCLUDED_SOURCE_FILE_NAMES or EXCLUDED_SOURCE_FILE_NAMES
The value is a space separated list of file paths
See reference:
http://lists.apple.com/archives/xcode-users/2009/Jun/msg00153.html

Flex - error 1046 - some .as files don't get importet

I received a Flex project and when trying to compile it i get a few 1046 errors that say the Type was not found or was not a compile-time constant MyClass
however - the respective files are listed on the top of the file in an import clause like this:
import com.folder1.folder2.folder3.MyClass;
and if i check the folder structure, MyClass.as is there.
however, if i type this same line (import com.folder1.folder2.folder3.MyClass;) and check at each . what the autocompletion suggests, I see only a subset of the as classes that are actually there on the harddisk.
What determines which classes and folders are suggested by the autocompletion function? I don't get any compile error on the corresponding import statements that import MyClass
//edit:
screenshot 1 shows the file in which the error occurs that tries to import the class in question (Updater)
http://neo.cycovery.com/flex_problem.gif
screenshot 2 shows the file Updater.as
http://neo.cycovery.com/flex_problem2.gif
the censored part of the path matches in both cases (folder structure and package statement in Updater.as)
screenshot 3 shows where the error actually happens:
http://neo.cycovery.com/flex_problem3.gif
interestingly, the variable declaration
private var _updater:Updater = new Updater();
further up in the file does not give an error
This project is set up wrong. Its obvious your application can not find the classes.
Move your "com" folder and all of the contents into your "src" folder.
Or perhaps include the files in your source path?
right click on the project name->properties->flex Build Path->add folder
the import is based on the 'package' declaration within the file itself (at the top of the file). If the file's package declaration does not match the actual folder structure, you will get problems.
Check the classes you can't see in the autocompletion list. Maybe those classes' package name doesn't match the actual structure.
Rob
Check your actionscript source paths. Any chance that the folders you are seeing (events and objects) are in there explicitly, and the others are not? Normally, you have all your source inside a folder like src that is in the source path, so that the compiler can find anything anywhere inside it. But you can just as easily make your source paths too specific and just see a few things...

Resources