In function âvoid warning: extra `â` gets appended somehow - c++

Whenever I compile my C++ code using make, I always get warning as -
/client/main.cc: In function âvoid print_rows(cql::cql_result_t&)â:
/client/main.cc:41:5: warning: label âstdâ defined but not used [-Wunused-label]
Somehow I always see â appended in my print_rows method and std as well.. But whenever I go on vi editor, I never see â appeneded..
Is there anything I am missing? How to fix this problem?

Related

Using map function to map to user options to specific function

I am new to C++ and need some help with the following:
If i have no namespace this works fine as soon as i have this i get a error :
(active) E0109 expression preceding parentheses of apparent call must have (pointer-to-)
I am attaching a solution where i have implemented this code to show the error.
What i am tryng to achive is to use this map to call my menu options a user can select, it has a header file as well as the cpp implemtation file in it.
I have attached the source code with the error showing when trying to compile this.
I would greatly appreciate some help - sample attached done in visual studio Sample Code
https://www.dropbox.com/s/j5nkxabjah313wz/SampleMenu.zip?dl=0

'v8::Value::ToNumber': was declared deprecated

I'm trying to access a known object and get one of its properties as a Number
Unfortunately, the following code...
Isolate *isolate = args.GetIsolate();
Local<Object> opts = args[0]->ToObject();
Local<Number> mode = opts->Get(String::NewFromUtf8(isolate, "mode"))->ToNumber();
is giving the following warning:
warning C4996: 'v8::Value::ToNumber': was declared deprecated
....node-gyp\8.5.0\include\node\v8.h(9578): note: see declaration of 'v8::Value::ToNumber'
In the v8.h I noticed the comment on ToNumber: "Use maybe version". I've attempted to convert it to a Maybe but I've not yet been able to get any attempt to compile correctly. What is the correct approach to using Maybe and getting the Number object?
Looks like the "Use maybe version" comment in the v8.h led me in the wrong direction. The deprecate notice seems to apply to the method-overload that is missing the isolate. If you pass the isolate...
->ToNumber(isolate);
it works without warning.

Why I am getting errors from TableGen-generated *.inc files (LLVM)?

I am trying to write an LLVM backend, when I am trying to build it, I get the following error message:
AbcGenRegisterInfo.inc: In static member function 'static const llvm::AbcFrameLowering* llvm::AbcGenRegisterInfo::getFrameLowering(const llvm::MachineFunction&)':
AbcGenRegisterInfo.inc:322:43: error: invalid static_cast from type 'const llvm::TargetFrameLowering*' to type 'const llvm::AbcFrameLowering*'
MF.getSubtarget().getFrameLowering());
^
Here is my AbcRegisterInfo.td (I copied it from here):
class AbcReg<string n> : Register<n> {
let namespace = "Abc";
}
def DUMMY_REG : AbcReg<"R0">;
def RegI64 : RegisterClass<"Abc", [i64], 64, (add DUMMY_REG)>;
I also overrided AbcSubtarget::getFrameLowering() method:
class AbcSubTarget : public AbcGenSubtargetInfo {
AbcFrameLowering *frameLowering;
// more fields and methods
const AbcFrameLowering *getFrameLowering() const override {
return frameLowering;
}
};
but the error message did not change.
I don't understand what to do - I can't just edit AbcGenRegisterInfo.inc, because it will be re-generated every time I will build LLVM, and I don't understand what's wrong in my TableGen files.
I also tried to remove AbcGenRegisterInfo.inc file from my build directory before compiling, but it had no effect.
Does AbcFrameLowering inherit from TargetFrameLowering? It looks like the static cast is complaining because the types are unrelated.
Also make sure the header with the definition of AbcFrameLowering is included before the .inc file is included otherwise the static cast will fail as well.
I have the same exact error, and while I cannot answer your question in full, I believe I can address one part of the issue. You said
I also tried to remove AbcGenRegisterInfo.inc file from my build directory before compiling, but it had no effect.
Unless you mean that AbcGenRegisterInfo.inc was regenerated (and therefore deleting it had no effect), the fact that its absence has no effect should be due to the fact that TableGen has the .inc.tmp file to rely on as a backup. I noticed that when I make with VERBOSE=1, there is a statement that suggests tablegen uses the .tmp files in this way.
Again, not a specific answer to your main question, but just to hopefully help address that issue when trying to debug.

C++ Does Not Name A Type

I get confused when I get errors like these
I have
FxSmartPtr<FxStreamable> able(FcNew,stream->StreamInObject());
FxGlobalPair pair(id,able);
I get an error on FxGlobalPair pair(id,able); that is able is not a type.
I tried modifying to
FxGlobalPair pair(id,FxSmartPtr<FxStreamable>::able);
but I get an error that is error: 'class FxSmartPtr<FxStreamable>::able' has not been declared
What concept am I missing?
UPDATE: typedef pair<FxID, FxSmartPtr<FxStreamable> > FxGlobalPair;
UPDATE 2:
Heading
I think that you have found the Most Vexing parse
The problem is that
FxSmartPtr able(FcNew,stream->StreamInObject());
may define a function named able, instead of a variable.

Passing enums to functions in C++

I have a header file with all the enums listed (#ifndef #define #endif construct has been used to avoid multiple inclusion of the file) that I use in multiple cpp files in my application.One of the enums in the files is
enum StatusSubsystem {ENABLED,INCORRECT_FRAME,INVALID_DATA,DISABLED};
There are functions in the application delcared as
ShowStatus(const StatusSubsystem&);
Earlier in the application when I made calls to the above function like
ShowStatus(INCORRECT_FRAME);
my application used to compile perfectly. But after some code was added The compilation halts giving the following error:
File.cpp:71: error: invalid conversion from `int' to `StatusSubsystem'
File.cpp:71: error: initializing argument 1 of `void Class::ShowStatus(const StatusSubsystem&)
I checked the code for any conflicting enums in the new code and it looked fine.
My Question is what is wrong with the function call that compiler shows as erroneous?
For your reference the function definition is:
void Class::ShowStatus(const StatusSubsystem& eStatus)
{
QPalette palette;
mStatus=eStatus;//store current Communication status of system
if(eStatus==DISABLED)
{
//select red color for label, if it is to be shown disabled
palette.setColor(QPalette::Window,QColor(Qt::red));
mLabel->setText("SYSTEM");
}
else if(eStatus==ENABLED)
{
//select green color for label,if it is to be shown enabled
palette.setColor(QPalette::Window,QColor(Qt::green));
mLabel->setText("SYSTEM");
}
else if(eStatus==INCORRECT_FRAME)
{
//select yellow color for label,to show that it is sending incorrect frames
palette.setColor(QPalette::Window,QColor(Qt::yellow));
mLabel->setText("SYSTEM(I)");
}
//Set the color on the Label
mLabel->setPalette(palette);
}
A strange side effect of this situation is it compiles when I cast all the calls to ShowStatus() as
ShowStatus((StatusSubsystem)INCORRECT_FRAME);
Though this removes any compilation error, but a strange thing happens. Though I make call to INCORRECT_FRAME above but in function definition it matches with ENABLED. How on earth is that possible? Its like while passing INCORRECT_FRAME by reference, it magically converts to ENABLED, which should be impossible. This is driving me nuts.
Can you find any flaw in what I am doing? or is it something else?
The application is made using C++,Qt-4.2.1 on RHEL4.
Thanks.
You should take the enum by value, rather than by const reference. It's small enough to fit into an int, so there is no performance penalty or anything like it.
But, from what you're describing, it sounds like somebody has #defined INCORRECT_FRAME to 0 elsewhere. You should put something like the following in the line above it:
#ifdef INCORRECT_FRAME
#error Whoops, INCORRECT_FRAME already defined!
#endif
BTW, the #ifndef thingy (for your header files) is called an include guard. :-)