|
Haven’t seen any standard term. If you need such term, I’d rather go for “inclusion point”. The word “reference” has many uses and adding another one is not going to make things clearer.
Anyway it has no direct relation to the linker. It is purely a textual inclusion and it will go through preprocessor and compiler before.
Mircea
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Sorry, I don't understand what you try to accomplish. Are you trying to document how your library has to be used by a client program? In this case, I've seen instructions like:
"... place an include directive to <cool_library.h> in your program"
or even:
"... place an include directive to <cool_library.h> before the include directive for <not_so_cool.h>"
If you are looking for something else, try to explain more.
Mircea
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
It is still not clear what you mean by "the process". There is no process as such, you just need to ensure that the compiler can find all declarations and/or definitions of any functions that you are trying to use. Either within your source file or in an associated header.
|
|
|
|
|
The source code may be using definitions of classes/functions etc in an external library. The header file provides this information so the compiler can create a reference in the object code. Such references will then be used by the linker to fix the links to a library or other object code module. For example given the followin directory structure:
PROJECT
LIB
CLIENT
you might have:
void Foo(char* name);
void Foo(char* name)
{
printf("Hello, World! A message from %s\n", name);
}
#include "../LIB/Library.h"
int main(int argc, char** argv)
{
Foo("fred");
return 0;
}
Does that make sense?
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Member 14968771 wrote: It does not clearly define what I was asking for. Maybe because your question did not clearly define what you were looking for.
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Member 14968771 wrote: The build process gets the #include of the library but fails to find the
first "#include in the library header file.
I am a little confused by some of your terminology, and also it is unclear which system you are using for the build. So a few possible ideas:
1. If this is using Visual Studio on Windows, you can add the locations of include directories to the Project settings. The compiler will search all such locations for include files.
2. If you are using a Makefile then add the include locations to the CPPFLAGS macro in the form "-I <include location>".
3. If the location of one of the headers is relative to the current directory then you can add the details to the #include statement thus:
#include "subdir\library.h"
4. If it is something else then please provide the details.
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
I have never used QTCreator so cannot offer any proper advice I am afraid. But from what you are saying you need to adjust some #include statements so that the compiler can find other files. And since we do not know the structure of your project or the content of the includes, it is difficult to guess what may be the actual change that is required.
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
/media/qe/TSET_QT_LABEL/QT_6/QT6_PRO/CAT/SUB_PRO/EXAMPLES_COPY/QT_5/Examples/Qt-6.2.0/bluetooth/btscanner_source/device.h:56:10: fatal error: qbluetoothlocaldevice.h: No such file or directory
56 | #include <qbluetoothlocaldevice.h>
There are two possibilities here:
1. Wherever this header file is located, it is not within any of the paths in the compiler's search list.
2. It is actually a local header file but has not been designated as such; try replacing the angle brackets by double quotes:
#include "qbluetoothlocaldevice.h"
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
I did explain earlier that I have never used QTCreator. I was trying what I know to be the normal rules in all the systems I have ever worked with. Both of my suggestions are the natural ones to try in such a situation. The fact that QTCreator uses some special system of its own is something I was totally unaware of, but assumed that you were.
|
|
|
|
|
How to make a scientific calculator in c++ or c along with file handling.....
|
|
|
|
|
|
Hi,
i'm a beginner in c++, i have already did some little projects but there is many years and i don't remember the most of things. I'm on c#, since many years (+a sickness that ruins my life, not good for the memory).
After several days of research, testing wmi, registry, c# c++/cli etc to measure performance, there was something i would find, how to remote since a drive letter (or path here) to know interface type. I finally found another articles of Raymond Chen, 90% of this code was already written by him i just made the link between and add what was missing. I understood the most of this, but i forgot a lot of syntaxes, memory management and few other things, because most of them are managed by c#. Then i would submit this code to know if there wase some things i could optimize, and most important if i correctly did things to not have an hardware problem beside.
Raymond Chen's blog
Futhermore i hope it will help others.
LPCWSTR filePath = L"H:";
HANDLE volumeHandle = NULL;
HANDLE driveHandle = NULL;
TCHAR volumePath[MAX_PATH]; bool res = GetVolumePathName(filePath, volumePath, ARRAYSIZE(volumePath));
wprintf(L"%s \n", volumePath);
TCHAR volumeName[MAX_PATH]; GetVolumeNameForVolumeMountPoint(volumePath, volumeName, ARRAYSIZE(volumeName));
wprintf(L"%s \n", volumeName);
CString test = volumeName;
test.TrimRight('\\');
LPCWSTR volumeNameWithoutTrailingBackslash = test;
volumeHandle = CreateFile(volumeNameWithoutTrailingBackslash,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
nullptr);
VOLUME_DISK_EXTENTS* extents = nullptr;
VOLUME_DISK_EXTENTS singleExtent;
std::unique_ptr<BYTE[]> lifetime;
DWORD bytesWritten;
if (DeviceIoControl(volumeHandle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
nullptr, 0,
&singleExtent, sizeof(singleExtent),
&bytesWritten,
nullptr))
{
extents = &singleExtent;
}
else
{
VOLUME_DISK_EXTENTS* lastQuery = &singleExtent;
while (GetLastError() == ERROR_MORE_DATA)
{
assert(RTL_CONTAINS_FIELD(lastQuery, bytesWritten, NumberOfDiskExtents));
DWORD extentCount = lastQuery->NumberOfDiskExtents;
DWORD allocatedSize = FIELD_OFFSET(VOLUME_DISK_EXTENTS, Extents[extentCount]);
lifetime.reset(new BYTE[allocatedSize]);
lastQuery = (VOLUME_DISK_EXTENTS*)lifetime.get();
if (DeviceIoControl(volumeHandle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
nullptr, 0,
lastQuery, allocatedSize,
&bytesWritten,
nullptr)) {
extents = lastQuery;
break;
}
}
}
if (extents)
{
int physicalDriveNumber = extents->Extents->DiskNumber;
wchar_t physicalDrivePath[80];
swprintf_s(physicalDrivePath, L"\\\\.\\PhysicalDrive%d", physicalDriveNumber);
driveHandle = CreateFile(physicalDrivePath,
0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr, OPEN_EXISTING, 0, nullptr);
STORAGE_PROPERTY_QUERY query{};
query.PropertyId = StorageAdapterProperty;
query.QueryType = PropertyStandardQuery;
DWORD bytesWritten;
STORAGE_ADAPTER_DESCRIPTOR result{};
if (DeviceIoControl(driveHandle, IOCTL_STORAGE_QUERY_PROPERTY,
&query, sizeof(query),
&result, sizeof(result),
&bytesWritten, nullptr))
{
printf("Interface type: %d", result.BusType);
}
}
CloseHandle(volumeHandle);
CloseHandle(driveHandle);
At the end, the number give the port used, check Here
|
|
|
|
|
If this is supposed to be an alternative to Raymond Chen's article, then you should post it there.
|
|
|
|
|
Hi, it's not an alternative i just filled the element missing to perform what i need, 90% of the code came from Raymond Chen's blog. I've seen many people would know as me, how to find if a logical drive was usb, etc... I'm not enough good to c++ to make an article with it. I just want to verify with the community if there is no problem with the way i close handle, if there is things i didn't see. Et cetera. c++ code i made by the past was not about windows api, was just simple ui then i gone to java then c# (worst is i have a sickess doing i lost a big part of what i learnt).
About the code, I saw many people using WMI but WMI could reach until 8s as i measured yesterday to retrieve information (i've hard 7 hard drive, 4 in usb 3) what is for a local application is a non-sense. Some others think DriveType is an hard disk is usb, what is false. An hard disk is considerate as "fixed" (Worse is for c# developper as me, there is no all possibilities we have with c++ except by c++/cli and it's not really a good idea to check logical drive by logical drive with c++/cli, it's slow in compareason. We need DriveInfo in c# it's slow.
This is why step by step i search with c++/windows api how to do and have something quick and each time i find an algorithm doing the job (by combining, searching etc...) i post for others. Things evoluted since 2003, and i found hard to sort what it's deprecated, most of answers i found, people use workarounds. And c# get logical drives give me not at all what i need, i'm frustrated .
Sorry for this long post.
|
|
|
|
|
Duc Axenn wrote: I just want to verify with the community if there is no problem The code is technically wrong. But don't worry... it's probably correct 99.99% of the time.
Did you write this code? The top half seems to be written by someone who knows that the file can span across multiple physical disks. The bottom half is incorrectly returning the STORAGE_BUS_TYPE of only the last disk extent.
Microsoft Windows supports spanned volumes[^] which means that in very rare cases a single file might be located on multiple physical disks. Those physical drives could be a mixture of SCSI, SATA, USB, ATAPI, NVME, etcetera...
To make your code more correct you would need to loop through all of those disk extents and return all of the storage bus types[^].
Best Wishes,
-David Delaune
edit: fixed typo
modified 24-May-21 9:06am.
|
|
|
|
|
|