|
Yeah I realized that after a while
|
|
|
|
|
I wouldn't try using library interpositioning for this sort of thing. While you can implement a DLL that calls selectively forwards functions to another DLL it ends up being a bit of a headache [1]. The approach I tend to use is...
- wrap the DLL in a class
- extract an interface class out of the class you've implemented (all the functions are pure virtual)
- implement the interface again, passing the bits you want through to the DLL and reimplementing the bits you don't want to
- select at runtime or compile time (depending on the type of testing you want to do) which implementation of the interface you want to use
This method is something to consider with any third party library so when it doesn't work properly you've got a central point to either replace it or patch its functionality.
Cheers,
Ash
[1] If you really want to do use library interpositioning then...
- reimplement the entire interface of the wrapped DLL, starting off by just returning succeeded, true, whatever is appropriate
- reimplement the functions you want to pass through by (a) manually loading the wrapped DLL and (b) calling the wrapped function
- reimplement the bits you don't want to pass through however you want
This saves the balls ache of link order of the wrapping and wrapped libraries.
|
|
|
|
|
So I can't simply use the external function definitions to expose those functions in the dll and statically link the lib file to the dll for the actual implementation??
Wrapping the dll in a class sounds like an overkill, I wanted something quick and dirty. If I try to use the library interpositioning you described at the bottom of your post, won't the functions I import from the wrapped dll clash with the functions I defined in the wrapper, being the same name and signature??
|
|
|
|
|
Not sure what you're talking about in the first paragraph (sorry!). When you define a function you're actually writing the code for it. At least in C++ terms, not sure what the C standard says about definitions.
Wrapping the DLL in a class may or may not be overkill. It's guarenteed to work and gives you a nice boundary to unit test around by adding something that's easily substitutable. If the DLL has a couple of hundred functions you're trying to use then it might be a headache (but then the DLL itself is likely to already be that) but for 20 or so functions it's less than an hours work.
As to the interpositioning I described... Why would there be any clash of names? You're not linking with the wrapped DLL so there are no names from it to clash with.
Cheers,
Ash
|
|
|
|
|
So doing dll import would not name clash with my local functions ?
|
|
|
|
|
Nope, I didn't say that. I said that if you don't link with the DLL then there'll be no names to clash with.
|
|
|
|
|
depends only shows exported function from current dll.
so if you want to show nested dll function then you should need to export the function.
|
|
|
|
|
how can i develop a file exe?
|
|
|
|
|
That's a really vague question, so I'll give you a vague answer: by writing code and compiling it. Now if you want a more precise answer, you'll need to give more details about your problem.
|
|
|
|
|
|
By following these steps:
- choose a programming language
- buy a good book about that language and study it
- write down your first project (usually each book starts with a very simple Hello World application)
- compile your project to produce the executable file
That's it!
|
|
|
|
|
i'm using visual studio but i have problem with the code project i'm learning le function
thanks
|
|
|
|
|
Do you mean how to use Visual Studio? Which language are you using (VC++, VC#, ...)?
We can speak italian if you prefer...
|
|
|
|
|
se parli in taliano va meglio.con visual studio creo i project ma non riesco a trasformarli con il comando compile
|
|
|
|
|
Il comando Compile non è quello di cui hai bisogno: esso esegue soltanto la compilazione del file che attualmente hai aperto nell'editor (se guardi nella cartella dei files intermedi troverai qualcosa tipo nomefile.obj).
Per ottenere il file eseguibile finale devi usare il comando Build oppure Rebuild.
|
|
|
|
|
il problema è che debbo imparare i codici da inserire nel file cercando su internet c'è di tutto
ma non so usare i comandi come include o le funzioni numeriche
|
|
|
|
|
In questo modo però rischi di diventare vecchio prima di aver imparato! Prova a partire da qui:
http://www.cerca-manuali.it/manuale-guida/c.htm[^]
Non li ho guardati tutti, ma sono in italiano e dovrebbero darti una panoramica di quello che serve per iniziare.
|
|
|
|
|
veramente vorrei imparare senza manuali tu dici che è possibile?
|
|
|
|
|
Per "imparare" servono sia teoria che pratica.
La sola teoria o la sola pratica sono ... masturbazioni. Possono essere divertenti, ma non producono nulla che duri a lungo.
L'"esperienza" si fa passando dall'una all'altra alternativamente su cose via via più complesse.
Se non hai tempo (ne passione) per questo, cambia mestiere.
Da quanto vedo, il modo assolutamente approssimativo con cui esprimi i concetti anche basilari ti sta già creando problemi di comunicazione ... chi ti deve rispondere fatica a cogliere di quale argomento parli. Non perché non lo conosci, ma perché usi una "lingua" tutta tua. Fatta sulla sola "pratica" che solo tu conosci.
Se insisti moooolto a lungo potrai anche diventare un grande esperto, che però non riuscirà mai a "vendere" nulla di ciò che produce e che difficilmente troverà compagni di avventura con cui lavorare su cose più complesse.
Non puoi imparare senza "studiare" ciò che altri hanno già "imparato" prima di te.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Sauro Viti wrote: We can speak italian if you prefer
Yeah great idea; now all the non-Italian speakers have no way of figuring out whether your suggestions are useful or not.
It's time for a new signature.
|
|
|
|
|
I'm very sorry Richard You are absolutely right... I tought to better help the enquirer, but I forgot the others... I try to fix my mistake:
albertodiprima said that he isn't able to produce an exe using the Compile command in Visual Studio: I told him not to use the Compile command, but Build or Rebuild.
By the comment of albertodiprima I supposed that he has lacks in basic concepts about C/C++ and development tools (he said that doesn't know how to use the #include directive and similar), then I suggested him to buy a book and a website where are available a number of tutorials on C/C++ and Visual Studio.
Now he say that doesn't like to learn using books nor tutorials and he'd like to learn completely by himself by trying and searching the internet, and he is asking what I think about...
|
|
|
|
|
Thanks for the translation. There is no problem with communicating with someone in your native language, but you should do it by direct person to person email and not in the forums.
It's time for a new signature.
|
|
|
|
|
Don't underestimate the italian to english Google translators.
50% of Italian techincal text is made by inglish words, and 30% of italian neologism taken from english!
It is vice-versa that is a nightmare (when you got the translation even of what shouldn't)
I often have to back-traslate italian to english to understand what the italian text really means!
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I've run that code on 2 core cpu
...
for (i = 0; i < N * N; i++)
vec3[i] = vec1[i] * vec2[i];
...
#pragma omp parallel for
for (i = 0; i < N * N; i++)
vec3[i] = vec1[i] * vec2[i];
...
Even if I run it by setting explicitly omp_set_num_threads(1) to use just one thread it runs about 1.66 times faster. Using 2 threads the speed up is 2 times.
I've checked with omp_get_thread_num() how many threads were running.
What is the reason for single thread OpenMP to outperform ordinary for loop?
Чесноков
|
|
|
|
|
Hi,
Well there many possibilities.
Even using the ordinary loop, you can get different perfromance results between writing :
for (i = 0; i < N * N; i++)
vec3[i] = vec1[i] * vec2[i];
and writing this :
for (i = 0; i < N * N; i+=2) {
vec3[i] = vec1[i] * vec2[i];
vec3[i+1] = vec1[i+1] * vec2[i+1];
}
So one hypothesis would be that the OpenMP look implementation knows the better way how to do the transfer of data.
The number of 1.66 should tell something. No doubt !
Let me guess, 1.66 is 5/3
If the process involves the repetition of N tasks, with each task lasting T duration then the new gain is 3/5 T
meaning we got rid of 2/5
There is a constant task, and that is the multiplication. It woud be too coincidential to get that 66 number if not the constant part is about the ..
Emmm I will think about this in the bus.
Good day.
1.66 means means
Easy Profiler : Now open source !
http://www.codeproject.com/KB/cpp/easyprofiler.aspx
|
|
|
|