portable code
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: portable code

  1. #1
    Join Date
    Apr 2009
    Posts
    638

    portable code

    these line isn't portable with Dev C++:
    Code:
    __declspec ( property ( put = SetText, get = GetText ) ) string Text ;
    can you tell me how cai fix it?

  2. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,365

    Re: portable code

    Not use property! As Paul already explained in another thread, this is not standard c++ (any version). If you want to use Dev c++ then you need to start using SetText(), GetText() etc in your code like the rest of us do!
    Last edited by 2kaud; August 23rd, 2013 at 01:25 PM.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Apr 1999
    Posts
    27,427

    Re: portable code

    Quote Originally Posted by Cambalinho View Post
    these line isn't portable with Dev C++:
    Code:
    __declspec ( property ( put = SetText, get = GetText ) ) string Text ;
    can you tell me how cai fix it?
    Learn C++ from C++ language books and resources, and not Windows OS books, websites or tutorials.

    If you did that, then there is no way you would have produced that line of code. I have been using C++ for over 20 years, and I have never seen any code like that.

    Regards,

    Paul McKenzie

  4. #4
    Join Date
    Apr 2009
    Posts
    638

    Re: portable code

    Quote Originally Posted by Paul McKenzie View Post
    Learn C++ from C++ language books and resources, and not Windows OS books, websites or tutorials.

    If you did that, then there is no way you would have produced that line of code. I have been using C++ for over 20 years, and I have never seen any code like that.

    Regards,

    Paul McKenzie
    that line is from Visual Studio 2010. so that's impossible do a 'real' property in c++, right?

  5. #5
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,387

    Re: portable code

    Quote Originally Posted by Cambalinho View Post
    that line is from Visual Studio 2010. so that's impossible do a 'real' property in c++, right?
    Where exactly is it from? Could you post a link to MSDN?
    Victor Nijegorodov

  6. #6
    Join Date
    Apr 2009
    Posts
    638

    Re: portable code

    Quote Originally Posted by VictorN View Post
    Where exactly is it from? Could you post a link to MSDN?
    http://msdn.microsoft.com/en-us/library/yhfk0thd.aspx

  7. #7
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,365

    Re: portable code

    Code:
    :__declspec ( property ( put = SetText, get = GetText ) ) string Text ;
    As the MSDN link says, this is Microsoft Specific and is NOT standard c++. I try to avoid non-standard, vendor specific c++ 'features' as much as possible.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  8. #8
    Join Date
    Apr 2009
    Posts
    638

    Re: portable code

    Quote Originally Posted by 2kaud View Post
    Code:
    :__declspec ( property ( put = SetText, get = GetText ) ) string Text ;
    As the MSDN link says, this is Microsoft Specific and is NOT standard c++. I try to avoid non-standard, vendor specific c++ 'features' as much as possible.
    understand, but ask me just these: if i use that line in Dev C++, the only error that i have seen is that don't recognize "put" and "get". thinking on these: these problem can be 'fixed'?

  9. #9
    Join Date
    Apr 1999
    Posts
    27,427

    Re: portable code

    As 2kaud stated, the link says "Microsoft specific".

    Again, if you had learned C++ in a more formal way, then there is absolutely no way you could have produced that line of code. If you're using Visual C++, then first and foremost, learn C++. Then apply the Windows API functions, structs and data types to your code. Even though functions, structs and data types aren't portable in the strict sense, they can be easily simulated by macros and dummy functions.

    However do not try different syntax that states "Microsoft specific" -- that will always fail to be portable, and no amount of restructuring will get it to work.

    Regards,

    Paul McKenzie

  10. #10
    Join Date
    Apr 1999
    Posts
    27,427

    Re: portable code

    Quote Originally Posted by Cambalinho View Post
    understand, but ask me just these: if i use that line in Dev C++, the only error that i have seen is that don't recognize "put" and "get". thinking on these: these problem can be 'fixed'?
    Do you understand how compilers work? Just because the compiler sees the word "put" and "get" means nothing.

    You have one line of code. The compiler must understand in total what that entire line is supposed to mean. It isn't just about seeing certain words. For example:
    Code:
    x I am a good boy;
    y I am a bad boy;
    So if the compiler says something about "x" and "y", does it mean it knows that I have posted something valid, instead of nonsense?

    Regards,

    Paul McKenzie

  11. #11
    Join Date
    Apr 2009
    Posts
    638

    Re: portable code

    Quote Originally Posted by Paul McKenzie View Post
    Do you understand how compilers work? Just because the compiler sees the word "put" and "get" means nothing.

    You have one line of code. The compiler must understand in total what that entire line is supposed to mean. It isn't just about seeing certain words. For example:
    Code:
    x I am a good boy;
    y I am a bad boy;
    So if the compiler says something about "x" and "y", does it mean it knows that I have posted something valid, instead of nonsense?

    Regards,

    Paul McKenzie
    you have right
    you are a good boy
    thanks for all

  12. #12
    Join Date
    Apr 2009
    Posts
    638

    Re: portable code

    why i can't use some console functions in Dev C++?
    the error is like they aren't declared. can you advice me?

  13. #13
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,365

    Re: portable code

    Quote Originally Posted by Cambalinho View Post
    why i can't use some console functions in Dev C++?
    the error is like they aren't declared. can you advice me?
    Probably because Devc++ hasn't been updated since 2005 and so doesn't have the current Micorosft SDK! I wouldn't recommend using it. See
    http://clicktobegin.net/programming/...dnt-use-dev-c/
    Last edited by 2kaud; August 23rd, 2013 at 01:26 PM.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  14. #14
    Join Date
    Apr 2009
    Posts
    638

    Re: portable code

    Quote Originally Posted by 2kaud View Post
    Probably because Devc++ hasn't been updated since 2005 and so doesn't have the current Micorosft SDK! I wouldn't recommend using it. See
    http://clicktobegin.net/programming/...dnt-use-dev-c/
    after some time and more help, i did it heheheh
    (and i share)

    Code:
    #ifdef __cplusplusextern "C" {
    #endif
    //seems that here you can declare all functions you need hehehe
    BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsoleOutput,BOOL bMaximumWindow,PCONSOLE_FONT_INFO lpConsoleCurrentFont);
    COORD WINAPI GetConsoleFontSize(HANDLE hConsoleOutput,DWORD nFont);
    HWND WINAPI GetConsoleWindow();
    #ifdef __cplusplus
    }
    #endif
    my dev C++ verison is 5.4.1(2013).
    thanks for all

  15. #15
    Join Date
    Apr 1999
    Posts
    27,427

    Re: portable code

    Quote Originally Posted by Cambalinho View Post
    why i can't use some console functions in Dev C++?
    First remember that Dev-C++ is not the compiler. The compiler is gcc.

    Second, in C++ you won't be able to use any functions if the functions are not declared. You can't compile any C++ module if you call a function that isn't previously declared, or if not declared, the entire function body exists before the call. Those are the rules of C++.

    If you want proof, try to compile this simple program:
    Code:
    int main()
    {
        double x = sqrt(4.0);
    }
    This will also not compile, since sqrt() isn't declared.

    Regards,

    Paul McKenzie

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center