Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Marcello

@Marcello
About
Posts
39
Topics
8
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • problem exporting static template data members, but not methods
    M Marcello

    Thank you so much for your answer, and for saving me a lot of time and trouble. You really went to the core of problem I am having. Unfortunately I worked for months to recode my program in separate DLL's in order to keep things separated. I personally think that DLL are also a mean to keep things separated, so to unify all of them in a unique DLL is something I will do only if I have no other choice. In my case I think I would rather find a way to eliminate the static member, even if it is really not a good solution because of the way my class is supposed to be used. Only a question. Why in Unix you didn't meet this problem ? ( I know a bit about Linux, but not very much. ) Best Regards, Marcello

    C / C++ / MFC help question csharp c++ visual-studio

  • Low level operations to devices
    M Marcello

    :) Yes, I meant fvalerin

    C / C++ / MFC csharp c++ dotnet json question

  • Low level operations to devices
    M Marcello

    I just saw this article: Hooking the kernel directly http://www.codeproject.com/useritems/soviet\_direct\_hooking.asp maybe he can help you ! Marcello

    C / C++ / MFC csharp c++ dotnet json question

  • problem exporting static template data members, but not methods
    M Marcello

    Thank you for the all answers. But the question I made is not a beginner's question. It is about exporting a static variable and if there is any reason why it is made so difficult to export it. We know that it is possible to export a static member from a template class specialization, We know that it is not possible to use the __declspec(dllexport) keyword with a template. But in the example I gave I was able to get a static methods of a template exported even if the __declspec(dllexport) was not used. But this is not happening with a static data member. The reason I am trying to do this is that I need to export and use a class created by using the Curiously Recurring Template Pattern (CRTP). In my case the template base class needs to have a static member. About the third question, I am pretty sure that it is possible by using an export file (.def) and using a special keyword in it [ unfortunately I don't remember exactly how :( ]. Cheers, Marcello

    C / C++ / MFC help question csharp c++ visual-studio

  • problem exporting static template data members, but not methods
    M Marcello

    Hello, Visual Studio 2005 From the help on: Compiler Warning (level 2) C4356 If I modify that example like:#include <iostream> template <class T> class C { static int n; }; class D : C<int> {}; // int D::n = 0; // C4356 int C<int>::n = 0;
    if I take this code and put it in a DLL like this:// file mydll.h : # if defined(MYLIB_EXPORTS) # define MYLIB_API __declspec(dllexport) # else # define MYLIB_API __declspec(dllimport) # endif template <class T> class C { static int n; static void show() { std::cout << "C:show()" << std::endl; std::cout << n << std::endl; } }; class MYLIB_API D : C<int> {}; // file mydll.cpp : // initialization of static member int C<int>::n = 3; // file myapp.cpp : #include "mydll.h" int main() { int k1 = D::n; // (a) error LNK2001: unresolved external symbol int k2 = C<int>::n; // (b) error LNK2001: unresolved external symbol D::show(); // Okay }
    The error I get, if I uncomment (a) or (b), is always: 1>myapp.obj : error LNK2001: unresolved external symbol "public: static int C<int>::n" (?n@?$C@H@@2HA) This makes sense because I am not exporting C. So the question is: 1.1) Why then method show() gets exported ? 1.2) In other words: Why the method gets exported and the data member not ? 2) Is there any way to export directly the data ? ( of course I could workaround the problem and access the static data member through a static method ) 3) A last question, a little different, but maybe related: If I try to export some data from a DLL, like: // file mydll.h : static MYLIB_API int mydata; // error C2201: 'mydata' : must have external linkage in order to be exported/imported MYLIB_API static int mydata2; // error C2201: 'mydata' : must have external linkage in order to be exported/imported I think that with vc70, if I remember well, I was not gettting any error message while compiling the DLL, but the LNK2001 error when linking the application. In other words I am always forced to export data as static data member of a class, ( which is in some cases very unconvenient), like:// file mydll.h : class MYLIB_API MyDataClass { static int data; }; // file mydll.cpp : int MyDataClass::data = 5;
    Is there a way to do it without using a class ? Thank you very much for

    C / C++ / MFC help question csharp c++ visual-studio

  • Overloads resolution crazyness ?
    M Marcello

    Thank you very much for the reply. Please forget about the VCF::String thing. It was a typo on my side. Here is a code I made for this question ( it compiles class Cond { public: typedef std::basic_string MyString; Cond() { }; virtual ~Cond(void) { }; Cond( const Cond& other ) { /* simple implementation just for this example */ *this = other; }; Cond& operator= ( const Cond& other ) { return *this; }; // implementation bool split( const MyString& s, MyString::size_type* p = NULL ); bool split( MyString& s, const bool& trim ); }; inline bool Cond::split( const MyString& s, MyString::size_type* p ) { /* simple implementation just for this example */ return true; } inline bool Cond::split( MyString& s, const bool& trim ) { MyString::size_type p; //if ( split( const_cast(s), &p ) ) // this compiles fine if ( split( s, &p ) ) // C2666 { s = s.substr( p + 1 ); return true; } return false; } I get the error message: 1>d:\projs\libraries\vcfex\src\conditions\test.h(51) : error C2666: 'vcfex::Cond::split' : 2 overloads have similar conversions 1> d:\projs\libraries\vcfex\src\conditions\test.h(37): could be 'bool vcfex::Cond::split(vcfex::Cond::MyString &,const bool &)' 1> d:\projs\libraries\vcfex\src\conditions\test.h(36): or 'bool vcfex::Cond::split(const vcfex::Cond::MyString &,stlp_std::basic_string<_CharT,_Traits,_Alloc>::size_type *)' 1> with 1> [ 1> _CharT=wchar_t, 1> _Traits=stlp_std::char_traits, 1> _Alloc=stlp_std::allocator 1> ] 1> while trying to match the argument list '(vcfex::Cond::MyString, stlp_std::basic_string<_CharT,_Traits,_Alloc>::size_type *)' 1> with 1> [ 1> _CharT=wchar_t, 1> _Traits=stlp_std::char_traits, 1> _Alloc=stlp_std::allocator 1> ] 1> note: qualification adjustment (const/volatile) may be causing the ambiguity It puzzles me that the C++ standard ( or is just vc80 ? ) is asking me to specify const_cast when intuitively the compiler should resolve the two overloads 'without effort'. A comment on this after the next point. I understand what you say at the second point. I agree but I am really surprised at the same time. I always considered a const function just as a way to tell the compler that that function is not going to change the 'this' pointer. So I ca

    C / C++ / MFC help c++ question regex tutorial

  • Overloads resolution crazyness ?
    M Marcello

    Hello, a question around the error C2666, under vc80 (RTM-8.0.50727.4200) Is it compliant to the C++ standard ? class CondParams { ... static bool getVariableState( const string& s, int& idx, string::size_type* p = NULL; // A static bool getVariableState( string& rs, int& idxVar, const bool& trim ); // B ); bool CondParams::getVariableState( string& rs, int& idx, const bool& trim ) { ... VCF::String::size_type p = 0; bool ok = getVariableState( rs, idx, &p ); if ( ok ) rs = rs.substr( p ); ... } I get the error message: 1>d:\projs\condparams.cpp(66) : error C2666: 'vcfex::CondParams::getVariableState' : 2 overloads have similar conversions 1> d:\projs\code\condparams.h(130): could be 'bool vcfex::CondParams::getVariableState(string &,int &,const bool &)' 1> d:\projs\code\condparams.h(129): or 'bool vcfex::CondParams::getVariableState(const string &,int &,string::size_type *)' 1> while trying to match the argument list '(string, int, size_type *)' 1> note: qualification adjustment (const/volatile) may be causing the ambiguity I could fix the problem by doing: 1) static bool getVariableState( string& s, int& idx, string::size_type* p = NULL; // A or by doing: 2) bool ok = getVariableState( const_cast(rs), idx, &p ); so I guess that the compiler is confused because it doesn't find any perfect match. The solution 1 is usually not acceptable. So I have to apply 2). But this situation is *very* common: why should I need to specify that a variable is constant each time I am using it as argument for a function that declared that is not going to modify it ? Also it doesn't logically seem necessary. It is like the Standard C++ ( or Microsoft? ) is forcing me to put a const_cast everywhere. This was not a problem with vc70. Similar issue, but not identical, with an example given in vc80 RTM help about the C2666 error. enum E { E_A, E_B }; class A { int h(const E e) const {return 0; } int h(const int i) { return 1; } // Uncomment the following line to resolve. // int h(const E e) { return 0; } void Test() { h(E_A); // C2666 h((const int) E_A); h((int) E_A); } }; Why the compiler shouldn't be smart enough to understand that int h(const E e) is a better match than int h(const int i) ? Why in earth int h(const E e) solves the problem, while int h(const E e) co

    C / C++ / MFC help c++ question regex tutorial

  • extern &quot;C&quot; in VisualStudio
    M Marcello

    Problem solved ! I had the feeling that vc70 was not reading this darn definition file, because by changing it it was not asking to rebuild. So I looked around and I found the option: Property Pages > Linker > Input > Module Definition File > and there I put AutoExp.def where the content is: LIBRARY AutoExpEx DESCRIPTION "Implements Custom Evaluator for Microsoft Debugger" EXPORTS VCF_VariantEvaluate @1 It works ! The linker screams both with the DLLEXPORT declaration and/or I do not use the '@' Note that the help in VisualStudio says that we should not specify the file in the environment, only to include it into the project ! But it works. Thanks a lot ! I really appreciated !

    C / C++ / MFC question html debugging

  • extern &quot;C&quot; in VisualStudio
    M Marcello

    Tried ! No success !

    C / C++ / MFC question html debugging

  • extern &quot;C&quot; in VisualStudio
    M Marcello

    What a cool program ! I dodn't know about it ! Thank you ! Under Depends it shows exactly as with dumpbin vc6: it appears as VCF_DateTimeEvaluate vc70: it appears as _VCF_DateTimeEvaluate@28

    C / C++ / MFC question html debugging

  • extern &quot;C&quot; in VisualStudio
    M Marcello

    Thank ou for all the help. I will try to check what you suggested me tomorrow ! Cheers, Marcello

    C / C++ / MFC question html debugging

  • extern &quot;C&quot; in VisualStudio
    M Marcello

    Thank you very much. At least an answer ! But it doesn't work :( This is my definition file for vc70: AutoExp.vcproj, AutoExp.cpp and AutoExp.def are all in the same directory AutoExp.vcproj has AutoExp.cpp and AutoExp.def in itself. Is there, maybe, some options in the project that creates problems ? Cheers, Marcello

    C / C++ / MFC question html debugging

  • Multiple Inheritance question
    M Marcello

    I am not a C++ guru, but this is how I understand the problem. You have a diamond pattern: I1 / \ I2 C1 \ / C2 I1::f=0 I2 f=? C1 f={} C2 ( f = I2::f or C1::f ? ) which you should always try to avoid when you use multiple inheritance. BTW: many people complain about multiple inheritance, but as long as you avoid a diamond patter, you'll be fine. So C2 is asking which f() should I make visible ? Your answer is: the one implemented. But this you know it only at linkage time. You need to implement f also in I2 and still you'll get an error because you still didn't answer the question ( f = I2::f or C1::f ? ) So you need to implement C2::f() { return C1::f(); } or you need to delete the declaration of f() in I1 Hope it clarifies.

    C / C++ / MFC question data-structures oop help

  • extern &quot;C&quot; in VisualStudio
    M Marcello

    Hello, I am using the tecnique http://www.lambdasoft.dk/comet/doc/cometautoexp.html in order to provides custom formatting for variables in the VisualStudio debugger. I can tell that it works very well. What puzzles me is this. In the code I export the function from the DLL in this way: extern "C" { __declspec(dllexport) HRESULT WINAPI VCF_DateTimeEvaluate( DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t maxlen, DWORD reserved ); } But then: dumpbin /exports AutoExp.dll shows _VCF_DateTimeEvaluate@28 instead than simply VCF_DateTimeEvaluate both by compiling with vc6 and vc70. Other people swear that I should simply get VCF_DateTimeEvaluate as long as I use: extern "C" { ... } Please note that extern "C" does something anyway, because without it I would get the mangled name: ?VCF_DateTimeEvaluate@@YGJKPAUtagDEBUGHELPER@@HHPADIK@Z If you have the patience to answer to another related question, here it is ! If I do use a definition file, it works with vc6 by just including it in the project, as I get: VCF_DateTimeEvaluate But with vc70 it doesn't work. Why ? What should I do different ?

    C / C++ / MFC question html debugging

  • tell filesystem to reload after I write
    M Marcello

    Did you notice that some applications like yours they eject the CD when they are finished ? And then they close the tray again ? Like Nero. Maybe because of the same problem you have. And most of applications playing music ( even Windows Media Player and NeroMix ) have the same problem. They have problems to automatically update their music list once he CD is inserted. It doens';t always work. M

    C / C++ / MFC question

  • VS.NET Debugging issues
    M Marcello

    Other people can answer you better than me. But I noticed that you "get the value of the variable. Instead I get the variable declaration information. " when the variable is nto valid at that moment, like a NULL pointer. For the second, look for the edit and continue compiler option and look also for the conditions when this is disabled.

    C / C++ / MFC debugging csharp visual-studio question

  • Lea allocator - can somebody please help me ?
    M Marcello

    Hello, sorry for posting this here. The question is: how to replace malloc with the Lea's allocator malloc ? http://gee.cs.oswego.edu/dl/html/malloc.html I tried everything but it doesn't work. I even posted this question to the author of its malloc replacement, Lea Dough. But my question is more windows related so he cannot answer me. At the same time I know that somebody here has been able to do it. Here is the list of what I did and of what some related question. But really what matter is that somebody is telling me how to do it. I am building a program build on top of other dynamic libraries. Everything using STLport. I created another static library, or dynamic I made as very first line of code in the first #if defined(USE_LEA) && defined(_WIN32) #pragma comment(lib, "libLea.lib") #endif If I #include malloc.h then I have compilers problem ( probably because the library is using precompiled headers ) like: c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\stdlib.h(291): error C2375: 'malloc' : redefinition; different linkage If I do not #include malloc.h then it compiles but at the end it is not using the malloc of Lea. I would like not to use detour. I don't think is a good idea to replace malloc.c malloc.h in the Visual Studio .NET\Vc7\include directory Can somebody help me ? Thanks a lot. Cheers, Marcello

    C / C++ / MFC help csharp question html visual-studio

  • A pixel from another program...
    M Marcello

    Thank you, I am realizing now that with Mozilla browser only the smileys appears, not the others.

    C / C++ / MFC question tutorial

  • A pixel from another program...
    M Marcello

    How do I add an achor tag ? How do I write a [code] section, which appears in light yellow if I remember well Is there a link that explains all of these things and others ? Thanks !

    C / C++ / MFC question tutorial

  • A pixel from another program...
    M Marcello

    Click on the smiling icon ! http://www.codeproject.com/gdi/screencolorpicker.asp The Code Project - Screen Color Picker - Fonts & GDI

    C / C++ / MFC question tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups