vc++ undeclared indentifier 2015 - visual-c++

Need help to resolve an error.
Currently I am working on a migration project from visual c++ 6.0 to visual studio c++ 2005.
And during compilation, I am getting "Undeclared Identifier Error"
I am hearing pasting the code and error.
code
const SMbfIndexCash* GetIxCashed(const CPoint& ptIxBlock, const short nMbfID)
{
SMbfIndexCash* pCashFound;
for(int ixFound=0; ixFound<MBF_IX_CASH_SIZE; ixFound++)
{
pCashFound=&ElementAt(ixFound);
if(pCashFound->nAge<0)
return NULL;
if(nMbfID==pCashFound->nMbfID && ptIxBlock==pCashFound->ptIxBlock)
break;
}
if(ixFound==MBF_IX_CASH_SIZE)
return NULL;
}
Error.
1>c:\cm and nemesis\cm code\cm 8.16\cm
8.16.0.1\source\cmoslib\tile.h(466) : error C2065: 'ixFound' :
undeclared identifier
Thank you.

The ixFound is now local to the scope of the for loop.
you need to do something like:
int ixFound = 0;
for(ixFound=0; ixFound<MBF_IX_CASH_SIZE; ixFound++)
{
//...
}
//...

Related

Why I am getting C3646 on an IAsyncAction declaration?

Probably a dumb question (WinRT noob), but, here is goes...
The code from "App.xaml.h" is:
namespace winrt::Precog::implementation
{
struct App : AppT<App>
{
App();
void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&);
private:
std::wstring cfgDatabase = L"";
winrt::Microsoft::UI::Xaml::Window window{ nullptr };
IAsyncAction loadSettings();
};
}
When I try to compile, Visual Studio gives me a C3646 (unknown override specifier) at the IAsyncAction declaration?
The loadSettings implementation is:
IAsyncAction App::loadSettings()
{
PHKEY regKey = NULL;
LSTATUS regResult;
regResult = RegCreateKey(HKEY_CURRENT_USER, L"Precog", regKey);
if (regResult != ERROR_SUCCESS)
{
ContentDialog errorDialog = ContentDialog();
errorDialog.Title(box_value(L"Erro"));
errorDialog.Content(box_value(L"Pateta"));
errorDialog.CloseButtonText(L"Ok");
errorDialog.XamlRoot(window.Content().XamlRoot());
auto result = co_await errorDialog.ShowAsync();
}
else
{
co_return;
}
}
EDIT: Full compiler output:
Build started...
1>------ Build started: Project: Precog, Configuration: Debug x64 ------
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3106: Assembly strong name "C:\Code\Precog\packages\Microsoft.WindowsAppSDK.1.0.0\build\native\..\..\lib\uap10.0\Microsoft.Windows.System.winmd" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2304,5): warning MSB3106: Assembly strong name "C:\Code\Precog\packages\Microsoft.WindowsAppSDK.1.0.0\build\native\..\..\lib\uap10.0\Microsoft.Windows.PushNotifications.winmd" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full assembly name it may contain characters that need to be escaped with backslash(\). Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
1>App.xaml.cpp
1>C:\Code\Precog\Precog\Precog\App.xaml.h(17,22): error C3646: 'loadSettings': unknown override specifier
1>C:\Code\Precog\Precog\Precog\App.xaml.h(17,34): error C2059: syntax error: '('
1>C:\Code\Precog\Precog\Precog\App.xaml.h(17,36): error C2238: unexpected token(s) preceding ';'
1>C:\Code\Precog\Precog\Precog\App.xaml.cpp(35,19): error C2039: 'loadSettings': is not a member of 'winrt::Precog::implementation::App'
1>C:\Code\Precog\Precog\Precog\App.xaml.h(7): message : see declaration of 'winrt::Precog::implementation::App'
1>C:\Code\Precog\Precog\Precog\App.xaml.cpp(48,30): error C2065: 'window': undeclared identifier
1>Done building project "Precog.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Got it. It seemed to be a namespace mismatch, since changing the declaration to:
winrt::Windows::Foundation::IAsyncAction loadSettings();
Solved the problem. The interesting bit is that Intellisense does not catch the error (no red line underneath the type), only the compiler does.

template 10 compiling error : 'PropertyChanged_ViewModel' does not exist in the current context.

i came from Microsoft course on edx, the template 10 is not working even after installing the NuGet Package, it gives me this error while compilling:
Error CS0103 The name 'PropertyChanged_ViewModel' does not exist in the current context.
and with double clicking on it, it takes me to the DetailPage.g.cs and the error is in this function :
public void UpdateChildListeners_ViewModel(global::solarizer.ViewModels.DetailPageViewModel obj)
{
if (obj != cache_ViewModel)
{
if (cache_ViewModel != null)
{
((global::System.ComponentModel.INotifyPropertyChanged)cache_ViewModel).PropertyChanged -= PropertyChanged_ViewModel;
cache_ViewModel = null;
}
if (obj != null)
{
cache_ViewModel = obj;
((global::System.ComponentModel.INotifyPropertyChanged)obj).PropertyChanged += PropertyChanged_ViewModel;
}
}
}
}
i deleted those if blocks and the error disappeared and the app ran but without the Hamburger Menu, any idea on how to fix this ??
Please consider updating the Template 10 Visual Studio Extension to at least version 1.7 and the NuGet package to at least 1.1.2. Then, create your project using the Hamburger template and let me know if it works.
takes me to the DetailPage.g.cs
Those .g.cs files are auto generated, and you shouldn't be modifying them. I think a clean build here would solve this issue, (especially after you've upgraded to a new version of T10)

Visual Studio 2012 complains about comparing two Brushes

Visual Studio 2012 complains about comparing two Brushes:
private void SetLabel(string stText, Brushes colorBackground)
{
if (colorBackGround == Brushes.Yellow)
...
}
Error message: "The name 'colorBackGround' does not exist in the current context"
colorBackGround is not the same as colorBackground! C# is case sensitive

VTable Not Generated

First of all, thank you very much for taking the time to look at my question. Second, I have read this and my class does not have any virtual methods I am forgetting to include. I'll go over additional things I have tried after I describe my problem.
I am getting an undefined reference to `vtable for SubcomponentTypeWidget' error when I build my code using gcc version 3.4.6 20060404. Visual Studio 2005 has no issues. I love Linux, but my current political situation has delegated it to the red headed step child that regularly suffers abuse. Hopefully by our powers combined, I can remedy that.
I am using Qt version 4.6.2. I am using gcc 3.4.6 20060404 on Red Hat 4.
This is my header:
#ifndef SubcomponentTypeWidget_h
#define SubcomponentTypeWidget_h
#include <vector>
#include "ui_SubcomponentTypeWidget.h"
#include "Subcomponent.h"
class SubcomponentTypeWidget : public QWidget, public Ui::SubcomponentTypeWidget
{
Q_OBJECT
Q_PROPERTY(QString title READ title WRITE setTitle)
public:
SubcomponentTypeWidget(QWidget* parent,
Models::Subcomponent::SubcomponentType subcomponentType = Models::Subcomponent::kSolid)
: QWidget(parent),
m_subcomponentType(subcomponentType),
m_subcomponentTypeButtonGroup(new QButtonGroup(this))
{
this->initialize();
}
Models::Subcomponent::SubcomponentType subcomponentType() const { return m_subcomponentType; }
void setSubcomponentType(Models::Subcomponent::SubcomponentType type);
void setNonCompatibleTypes(const std::vector<Models::Subcomponent::SubcomponentType>& types);
QString title() const { return m_subcomponentGroupBox->title(); }
void setTitle(const QString &title) { m_subcomponentGroupBox->setTitle(title); }
signals:
void subcomponentTypeChanged();
protected slots:
void handleSubcomponentTypeChoice(int subcomponentTypeChoiceId);
protected:
void initialize();
Models::Subcomponent::SubcomponentType m_subcomponentType;
QButtonGroup* m_subcomponentTypeButtonGroup;
};
#endif // SubcomponentTypeWidget_h
The implementation is here:
#include "SubcomponentTypeWidget.h"
void SubcomponentTypeWidget::setSubcomponentType(Models::Subcomponent::SubcomponentType type)
{
if (type != m_subcomponentType)
{
m_subcomponentType = type;
emit subcomponentTypeChanged();
}
}
void SubcomponentTypeWidget::setNonCompatibleTypes(const std::vector<Models::Subcomponent::SubcomponentType>& types)
{
m_subcomponentTypeButtonGroup->button(static_cast<int>(Models::Subcomponent::kSolid) + 1)->setEnabled(true);
m_subcomponentTypeButtonGroup->button(static_cast<int>(Models::Subcomponent::kComplement) + 1)->setEnabled(true);
m_subcomponentTypeButtonGroup->button(static_cast<int>(Models::Subcomponent::kHole) + 1)->setEnabled(true);
for (std::vector<Models::Subcomponent::SubcomponentType>::const_iterator it = types.begin(); it != types.end(); ++it)
{
m_subcomponentTypeButtonGroup->button(static_cast<int>(*it) + 1)->setEnabled(false);
if (*it == m_subcomponentType)
m_subcomponentTypeButtonGroup->button(static_cast<int>(Models::Subcomponent::kSolid) + 1)->setChecked(true);
}
}
void SubcomponentTypeWidget::handleSubcomponentTypeChoice(int subcomponentTypeChoiceId)
{
if (static_cast<Models::Subcomponent::SubcomponentType>(subcomponentTypeChoiceId - 1) != m_subcomponentType)
{
m_subcomponentType = static_cast<Models::Subcomponent::SubcomponentType>(subcomponentTypeChoiceId - 1);
emit subcomponentTypeChanged();
}
}
void SubcomponentTypeWidget::initialize()
{
this->setupUi(this);
m_subcomponentTypeButtonGroup->addButton(m_solidRadioButton, static_cast<int>(Models::Subcomponent::kSolid) + 1);
m_subcomponentTypeButtonGroup->addButton(m_complementRadioButton, static_cast<int>(Models::Subcomponent::kComplement) + 1);
m_subcomponentTypeButtonGroup->addButton(m_holeRadioButton, static_cast<int>(Models::Subcomponent::kHole) + 1);
m_subcomponentTypeButtonGroup->button(static_cast<int>(m_subcomponentType) + 1)->setChecked(true);
connect(m_subcomponentTypeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(handleSubcomponentTypeChoice(int)));
}
The actual error messages I am receiving are:
../lib/libMeshAndGeometry.a(AddAdvancedDialog.o)(.gnu.linkonce.t._ZN20Ui_AddAdvancedDialog7setupUiEP7QDialog+0x955): In function `Ui_AddAdvancedDialog::setupUi(QDialog*)':
: undefined reference to `vtable for SubcomponentTypeWidget'
../lib/libMeshAndGeometry.a(AddAdvancedDialog.o)(.gnu.linkonce.t._ZN20Ui_AddAdvancedDialog7setupUiEP7QDialog+0x960): In function `Ui_AddAdvancedDialog::setupUi(QDialog*)':
: undefined reference to `vtable for SubcomponentTypeWidget'
../lib/libMeshAndGeometry.a(AddAdvancedDialog.o)(.gnu.linkonce.t._ZN20Ui_AddAdvancedDialog7setupUiEP7QDialog+0x99b): In function `Ui_AddAdvancedDialog::setupUi(QDialog*)':
: undefined reference to `SubcomponentTypeWidget::initialize()'
../lib/libMeshAndGeometry.a(AddBoxDialog.o)(.gnu.linkonce.t._ZN15Ui_AddBoxDialog7setupUiEP7QDialog+0xfe8): In function `Ui_AddBoxDialog::setupUi(QDialog*)':
: undefined reference to `vtable for SubcomponentTypeWidget'
../lib/libMeshAndGeometry.a(AddBoxDialog.o)(.gnu.linkonce.t._ZN15Ui_AddBoxDialog7setupUiEP7QDialog+0xff3): In function `Ui_AddBoxDialog::setupUi(QDialog*)':
: undefined reference to `vtable for SubcomponentTypeWidget'
../lib/libMeshAndGeometry.a(AddBoxDialog.o)(.gnu.linkonce.t._ZN15Ui_AddBoxDialog7setupUiEP7QDialog+0x102e): In function `Ui_AddBoxDialog::setupUi(QDialog*)':
: undefined reference to `SubcomponentTypeWidget::initialize()'
../lib/libMeshAndGeometry.a(AddConeDialog.o)(.gnu.linkonce.t._ZN16Ui_AddConeDialog7setupUiEP7QDialog+0x7ef): In function `Ui_AddConeDialog::setupUi(QDialog*)':
: undefined reference to `vtable for SubcomponentTypeWidget'
../lib/libMeshAndGeometry.a(AddConeDialog.o)(.gnu.linkonce.t._ZN16Ui_AddConeDialog7setupUiEP7QDialog+0x7fa): In function `Ui_AddConeDialog::setupUi(QDialog*)':
: undefined reference to `vtable for SubcomponentTypeWidget'
../lib/libMeshAndGeometry.a(AddConeDialog.o)(.gnu.linkonce.t._ZN16Ui_AddConeDialog7setupUiEP7QDialog+0x835): In function `Ui_AddConeDialog::setupUi(QDialog*)':
: undefined reference to `SubcomponentTypeWidget::initialize()'
../lib/libMeshAndGeometry.a(AddCylinderDialog.o)(.gnu.linkonce.t._ZN20Ui_AddCylinderDialog7setupUiEP7QDialog+0x9c4): In function `Ui_AddCylinderDialog::setupUi(QDialog*)':
: undefined reference to `vtable for SubcomponentTypeWidget'
../lib/libMeshAndGeometry.a(AddCylinderDialog.o)(.gnu.linkonce.t._ZN20Ui_AddCylinderDialog7setupUiEP7QDialog+0x9cf): In function `Ui_AddCylinderDialog::setupUi(QDialog*)':
: undefined reference to `vtable for SubcomponentTypeWidget'
../lib/libMeshAndGeometry.a(AddCylinderDialog.o)(.gnu.linkonce.t._ZN20Ui_AddCylinderDialog7setupUiEP7QDialog+0xa0a): In function `Ui_AddCylinderDialog::setupUi(QDialog*)':
All of my makefiles have been generated from my .pro file using qmake. The main make files, the main .pro file, and the widgets and MeshAndGeometry make and .pro files are attached here as an archive. One of the .ui files is attached here.
I have tried a number of things.
I am sure this is not a stale object file issue. I have built this from scratch and I still have the the problem.
I checked all of my capitalization issues. One of the problems I have noticed with doing most of this on Windows and then moving it to Linux is that people make mistakes with capitalization, and Windows doesn't care about capitalization.
I ran nm -a -C SubcomponentTypeWidget.o to see if the necessary vtable was there, and it wasn't. However, the 'missing' methods were there.
Creating a virtual destructor does not force vtable generation for SubcomponentTypeWidget.
I have tried removing large chunks of SubcomponentTypeWidget's functionality. This results in removing the specific linker error messages for methods, but it does not remove the undefined reference to vtable message. I have removed everything from SubcomponentTypeWidget other than the constructor, and in this case I still receive the "undefined reference to vtable" message, but without any mention to specific methods we are looking for.
Changing the order of which widgets and MeshingAndGeometry are linked in does not help.
I have tried gcc versions 3.4.6 20060404 and 4.1.2 20080704.
Help me, Obi-Wan Kenobi. You're my only hope.
Thank you all very, very much,
-Brian J. Stinar-
went through your codes the error most likely arises from the following statement:
=======================================================
void SubcomponentTypeWidget::initialize()
{
this->setupUi(this);
//rest of codes
}
=======================================================
you are sort of breaking the structure of Qt by making SubcomponentTypeWidget a subclass of Ui::SubcomponentTypeWidget. You are actually using yourself to setup a UI of yourself in this case. Coupled that with the fact that you are using multiple class inheritance, you are just confusing the compiler on which virtual method to refer to during runtime.
Instead of subclassing Ui::SubcomponentTypeWidget, just make it a private variable in SubcomponentTypeWidget
//SubcomponentTypeWidget.h
private:
Ui::SubcomponentTypeWidge ui;
implement the following in your init function and you should be good to go
void SubcomponentTypeWidget::initialize()
{
ui.setupUi(this);
//rest of codes
}
My problem was with solution point number six. I actually did NOT change this order correctly. I was changing the order in the INCPATH instead of the order in the LIBS.
After adding the line MeshAndGeometry.depends = widgets to my master.pro file, running qmake, and running make, this problem went away.
Thank everyone very much for their comments and help.
-Brian J. Stinar-

Trying to experiment with some Resharper Open APIs

I was trying to read a C# source file and parse it using Resharper. I wanted to get the list of namespaces used in the file but I had an exception in this line.
ICSharpFile file = CSharpParserUtil.Parse(sCode);
Exception Details:
A first chance exception of type 'System.InvalidOperationException' occurred in
JetBrains.Platform.ReSharper.Shell.dll
The thread 0x1020 has exited with code 0 (0x0).
The thread 0x14c0 has exited with code 0 (0x0).
static void Main()
{
String sCode = File.ReadAllText(#"D:\ResharperTries\TestFile.cs");
try
{
ICSharpFile file = CSharpParserUtil.Parse(sCode);
IList<ICSharpNamespaceDeclaration> x = file.NamespaceDeclarations;
foreach (ICSharpNamespaceDeclaration value in x)
{
Console.WriteLine(value.ContainingNamespace.ShortName);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
Need some help regarding this issue.
Thanks
It is possible to do this with the parsers that are part of DXCore and CodeRush.
In version 10.2 we released stand-alone parser libraries for C# and VB (part of the freely downloadable DXCore), so referencing the parser libraries will make it very easy to do what you’re looking for.
If you need help with this, simply email support#devexpress.com with any questions.
Here is sample of code, which can be used to fill ListBox with namespaces, used in some file:
string filePath = #"InsertFilePathHere";
CSharp30Parser parser = new CSharp30Parser();
SourceFile fileNode = parser.ParseFile(filePath) as SourceFile;
if (fileNode == null || fileNode.UsingList == null)
return;
lbUsedNamespaces.Items.Clear();
for (int i = 0; i < fileNode.UsingList.Count; i++)
{
string strUsing = fileNode.UsingList.GetKey(i) as String;
if (String.IsNullOrEmpty(strUsing))
continue;
lbUsedNamespaces.Items.Add(strUsing);
}
Currently, it's impossible to use ReSharper API without Visual Stdio as in your example with console app.
You need to write R# plugin and it will be loaded into R# in Visual Studio.
Take a look at http://resharperpowertoys.codeplex.com/

Resources