I am trying to use the computeMeanAndCovarianceMatrix function from PCL in ROS. I researched online and saw that the function is defined in a centroid.hpp file, so I put #include <pcl_ros/centroid.h> at the top of my file but I still get a No such file or directory #include <pcl_ros/centroid.h>. Can someone help me with what include statement I have to put up so the function works?
Figured it out. You need to add #include <pcl/common/centroid.h>
Related
According to AutoIt's online reference:
It is quite common to have the same "#include " line in several of the files included included in a script. If the same file were to be included several times, it is quite likely that this would generate a "Duplicate function" or "Cannot redeclare a Const" error. So when writing a script intended for use as an include file, add #include-once to prevent that file from being included more than once. Note that the #include-once line must be placed at the top of the script and before any other #include lines.
It is not recommended to add a #include-once line to scripts which are not intended to be used as include files within other scripts.
So #include-once should not be used in scripts that are not intended to be included in other scripts. Why?
If the benefit of using #include-once is to prevent errors triggered by duplicate #include, then what is the benefit(s) of using #include over #include-once?
"… what is the benefit(s) of using #include over #include-once?"
None; they serve different purposes.
#include <filename.au3> includes filename.au3. #include-once (no parameters) prevents a file containing that directive from being included more than once.
If two different include files contain #include <FileConstants.au3> and FileConstants.au3 contains #include-once, then FileConstants.au3 does not get added again on inclusion of the second file (preventing constant- and function re-declaration errors). Usually every to be separately included file starts with #include-once.
"So #include-once should not be used in scripts that are not intended to be included in other scripts. Why?"
It serves no purpose. Effects (if any) classify as undocumented behavior (unintended by developers and subject to unannounced changes).
"When should #include be used over #include-once?"
You could use #include to execute code from another file at a certain (or multiple) other location(s) from within a file.
I am attempting to port the DirectX11/XAML UWP template over to a C++-WinRT version... where EVERYTHING is done via C++-WinRT and I can turn off CX.
I'm currently stuck on how to ResizeBuffers on the swapchain. I keep getting the error that says I haven't released all of the buffer references. If I comment out anything to do with resizing buffers and just hardcode in a size, the app works. So... I am probably doing something wrong.
I believe it has to do with the new winrt::com_ptr. There is no Reset method like on the WRL ComPtr. I have set them to nullptr just like in the original C++/CX templates, but that doesn't seem to be enough.
Other things I've had to do that may have an affect on what's going on:
The DeviceResources class is now a C++/WinRT class that I am creating by default in all of the other classes (SampleScene3DRenderer, DirectXPage, & Main) using the nullptr_t parameter. That way, I can create it in the DirectXPage, pass in the swapChainPanel reference, then pass this one DeviceResources instance to all of the other classes I create.
There's one spot in the DirectX initialization where you have to pass in a **IUnknown. The docs for C++/WinRT mention using a function called winrt::get_unknown to return an *IUnknown. I couldn't get it to work for the following DWriteCreateFactory method so I tried it this way:
DX::ThrowIfFailed(
DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED,
__uuidof(IDWriteFactory3),
reinterpret_cast<::IUnknown**>(m_dwriteFactory.put())
)
);
I'm not sure what else to do. Only the swapchain resizing doesn't work. I'm doing this on PC (not windows phone).
The DWriteCreateFactory call using winrt::com_ptr<T> and the put member above is correct. Also using nullptr assignment is the correct way to reset a com_ptr<T>.
com_ptr<IUnknown> ptr = ...
assert(ptr);
ptr = nullptr;
assert(!ptr);
You can also use winrt::check_hresult rather than ThrowIfFailed if you wish to be consistent with how C++/WinRT reports errors. Here's a simple DirectX example written entirely with C++/WinRT:
https://github.com/kennykerr/cppwinrt/blob/master/Store/Direct2D/App.cpp
I had the same problem. Now, it works after I moved my include for unknwn.h to before all of the winrt includes.
// pch.h
#pragma once
#include <unknwn.h>
#include <winrt/windows.globalization.datetimeformatting.h>
#include <winrt/windows.web.syndication.h>
#include <winrt/windows.foundation.collections.h>
#include <winrt/windows.foundation.numerics.h>
#include <winrt/windows.graphics.display.h>
#include <winrt/windows.applicationmodel.h>
#include <winrt/windows.applicationmodel.activation.h>
#include <winrt/windows.applicationmodel.core.h>
#include <winrt/windows.ui.h>
// #include <winrt/Windows.ui.core.h>
#include <winrt/Windows.UI.Core.h>
#include <winrt/windows.ui.composition.h>
#include <iostream>
#include <d2d1_1.h>
#include <d3d11.h>
#include <d3d11_2.h>
#include <d3d12.h>
#include <dxgi1_2.h>
I am just playing around with std::array. Want to pass an array of integers to a function which can easily be done using
void arrayByValue(array<int, 5> arr);
The above can be invoked like
array<int, 5> aInt = {100,92,-1,122,112};
arrayByValue(aInt);
This works perfectly fine as long as it is in same .cpp file.
I am The issue is how to put this in a .h file, implement the method in .cpp file and then invoke it in another file assume main. I receive the error saying
'array': undeclared identifier
type 'int' expected
Please suggest what could be wrong. Please note this works perfect if I declare the function in the same file from where I am invoking it
You need to add at the top of you .h file:
#include <array>
also use std::array - using namespace std; is a bad habit
Apologies for the inconvenience. I forgot to use
using namespace std;
in the .h file. Using the above line or using std::array
resolved the issue
I'm trying to get some old C(ish) code to compile but it doesn't define ResFileRefNum and I can't seem to find it anywhere in the official header files.
There's a definition in the documentation that degenerates to an int, and I can just drop that in if I have to, but I'd rather do it the right way, i.e. #include a header that defines the type.
Edit: I found the definition in the header Resources.h in the CarbonCore framework, but seem to be unable to #include it in the program.
CarbonCore is a sub-framework within the CoreServices umbrella framework. Just include the main header of that umbrella framework:
#include <CoreServices/CoreServices.h>
I have been trying to enable syntax highlighting and see call hierarchy for code which is embedded in #ifdedfine block but I am not able to find the option for it. Could anyone please point me at how to do it? It works well for other code/files it's just the code in #ifdef block (e.g. #ifdef CPP_UNIT....#endif). Thanks.
Code in #ifdef blocks IS syntax-highlighted IF THE CODE IS ACTIVE (e.g. if you have a #ifdef Q_OS_WIN and somewhere in your included headers Q_OS_WIN is defined, the code will be highlighted. Otherwise, it will be grayed-out.)
As a test, try temporarily replacing #ifdef ... with #if 1. If the latter works, then you know that ... is undefined by that file or any included files.