|
|
Yeah. There is such approach like, count the number of ticks to estimate performance. I do not think that it's panacea.
Richard MacCutchan and Jochen Arndt also correct.
But I guess that you mean universal and independent implementation version. Look here.
|
|
|
|
|
|
This is probably what you need:
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
void test(){
int i;int s=0;
for(i=1; i<1000000; i++){s+=sin(i)/i;}
}
int main(void)
{
clock_t time[2], timediff;
float elapsed;
time[0] = clock();
f1();
time[1] = clock();
elapsed = ((float)abs(time[0] - time[1]))/CLOCKS_PER_SEC;
printf("Code executed in %f milliseconds.\n", elapsed);
return 0;
}
|
|
|
|
|
I am an innocent bystander of a discussion about how #include directive is handled in IDE.
The IDE in question uses proprietary file "main" name extension (still a text file) and processes #include <header.h> and #include "local_header.h" in that file just fine.
However, when the local_header.h file has <b>another #include <header_1.h></b> in it the compiler "does not see that". That is basically what people who "knows / developed" the IDE are saying.
Including another local file in first local file such as #include "local_header_1.h" is "seen / processed " by IDE.
I was under the impression that #include <file.h > tells the OS to find the file "anywhere" and #include "file.h" tells the OS to search only current / parent directory.
So why is IDE (gcc) getting into the act?
|
|
|
|
|
#include <file>
This variant is used for system header files. It searches for a file named file in a standard list of system directories.
#include "file"
This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>.
https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html[^]
|
|
|
|
|
FTFY
Chris Losinger wrote: This variant is used for system or library header files.
|
|
|
|
|
Vaclav_Sal wrote: However, when the local_header.h file has <b>another #include <header_1.h></b> in it the compiler "does not see that". That is wrong. The compiler (or more precise: the preprocessor part) will process such includes.
However, an IDE may do other things with your files before they are passed to the compiler. But GCC is the Gnu Compiler Collection (a collection of command line tools) and not an IDE.
|
|
|
|
|
A compiler is not an IDE. An IDE is a front-end to a compiler and it should follow the same rules as the compiler (and pre-processor in this case). If the IDE does not, then it is broken and must be fixed.
|
|
|
|
|
Thanks for confirming my suspicions.
Obviously I got the compiler mixed up , so here is the way I view the whole mess.
To get from idea to running code I see these basic blocks
Operating system - with environment configuration
Development application (IDE )
Development tools
Text editor
Main file .*ino
"System " includes - example <stdio.h>
IDE "libraries" - example <LiquidCrystal.h>
Local includes - example "MyClass.h"
Compiler / linker (preprocessor)
Executable code
I think I need to take a look how the compiler handles / finds the path to each include.
I can see if local includes are in SAME directory as the x.ino file it works fine.
But the "system" or "library" includes path are different and that why if fails.
But I want to write code and not troubleshoot the IDE.
Maybe I should use a different IDE.
Cheers
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: But I want to write code and not troubleshoot the IDE. There is nothing to troubleshoot. Whether you use the IDE or not, the issues are the same. The compiler needs to know the paths of any directories which contain header files that you wish to include in your compilations. The linker needs to know the paths of any directories which contain libraries that are referenced by your project. When you install Visual Studio it sets a default set of both, which gives the paths to all the default library components. If you create a project that uses other headers and libraries then you need to add those paths, and the library names, using the Project Properties link in Solution Explorer. If you want to do it without using the IDE then it is much more hard work and you would probably need to set up some complex batch files, or learn how to use Make: something that is not for the fainthearted.
|
|
|
|
|
Richard, I feel you missed my question.
Just FYI, the IDE I am using is pretty tight lipped about "an additional path" I experienced using my VC++. It just was not build to expand...
I posted my question here for reasons which I do not wish to discuss.
Thanks anyway.
|
|
|
|
|
Vaclav_Sal wrote: I feel you missed my question. No, I think it was clear enough.
Vaclav_Sal wrote: I posted my question here for reasons which I do not wish to discuss. Then maybe you should not have posted it.
|
|
|
|
|
Vaclav_Sal wrote: Main file .*ino Are you working with Arduino?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Yes,
I'll take wild guess what you are going to say...on better not...
Anything after ONE file is a challenge.
|
|
|
|
|
Vaclav_Sal wrote: I'll take wild guess what you are going to say...on better not...Anything after ONE file is a challenge. Negative. I was just trying to narrow down the problem a bit. The Arduino IDE uses the avr-gcc compiler. That compiler's preprocessor, like others, has a list of directories it will search to resolve #include directives. This is usually the -I command-line switch.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi i am developing an application CListCtrl based, which can open more files listed inside, to do this i did thread for every file will be clicked, the problem is when i close a file i'd like to do some check operations on file, but using WaitForMultipleObjects it wait first i close all files and then perform the operations, with WaitForSingleObjects it wait only for first file and ignore the others.
I'd like so:
1) i open the file1.pdf - the program wait.
2) i open the file2.pdf - the program wait.
3) i close the file "file1.pdf" - the program perform operations on file1 (the file2.pdf is waiting)
Please i hope somebody can help me
Giovanni
|
|
|
|
|
WaitForMultipleOjects has a flag that decides whether it waits for all the handles to be signaled, or just one.
Read the documentation.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi thanks for response
i have already tried about WaitForMultipleObjects but the function wait until all opened files will be closed if i flag it TRUE.
If a flag it FALSE become similar to WaitForSingleObjects
|
|
|
|
|
The return value from WaitForMultipleObjects tells you which handle was signaled. You're supposed to check the return value to figure out which handle was signaled.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
i try to understand you i need to do this:
open 3 pdf with WaitForMultipleObjects(Array.GetCount(), Array.GetData(), FALSE, INFINITE);
and after user modifed pdf i need to save and delete from TMP folder.
if i use FALSE like i show you first i obtain the right signaled file number but the file was deleted without open becouse WaitForMultipleObjects do not block the execution maybe becouse the acrobat is already loaded
|
|
|
|
|
Giovanni they already explained to you that WaitForSingleObjects returns with the index of the event in the array that has been set.
When you get it simply inspect the return value, identify the file and execute the operations sequential to file closure.
Then remove the event from the array then repeat the WaitForSingleObjects with one element less in array. Repeat it until there are no more events in the array.
Buona fortuna.
|
|
|
|
|
I have tried for all day and i have always the same for first file is all ok and from second the system do not wait, becouse my english is not perfect like yours i luckly found an user response to show you so i can be more specific:
"What happens depends on the application that is registered to open PDF or JPG files. If you open the documents in an SDI application, then every CreateProcess() call returns a process handle for an application, which you can wait for - this will return when the application editing the document closes.
If however an application is limited to a single instance, then every further call will return as soon as the new instance has passed the data to the first instance (which will usually open the document in a new frame), and then has exited. I think that is what happens in your case, probably you are using Acrobat Reader to open the PDF files"
The problem for me is clear the question is: it's possibile manage this problem using some workaround?
|
|
|
|
|
Let me understand:
1. you don't open the files in your program, but you create a new process to run an app that open the file.
2. You are not waiting on a file, but on the process to end. So if the process opens multiple files you got no notifications.
If this is the scenario maybe you have to use a different strategy to be notified right on files changes. Check the directory change notifications[^] 
|
|
|
|
|
Right now you have understood i was looking for directory change but i haven't found something as example to test the possibility, if you can show me some example please
|
|
|
|