-
August 23rd, 2013, 08:17 AM
#1
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?
-
August 23rd, 2013, 09:15 AM
#2
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
August 23rd, 2013, 09:26 AM
#3
Re: portable code
Originally Posted by Cambalinho
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
-
August 23rd, 2013, 10:22 AM
#4
Re: portable code
Originally Posted by Paul McKenzie
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?
-
August 23rd, 2013, 10:33 AM
#5
Re: portable code
Originally Posted by Cambalinho
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
-
August 23rd, 2013, 10:39 AM
#6
Re: portable code
Originally Posted by VictorN
Where exactly is it from? Could you post a link to MSDN?
http://msdn.microsoft.com/en-us/library/yhfk0thd.aspx
-
August 23rd, 2013, 11:24 AM
#7
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
August 23rd, 2013, 11:27 AM
#8
Re: portable code
Originally Posted by 2kaud
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'?
-
August 23rd, 2013, 11:36 AM
#9
Re: portable code
Originally Posted by Cambalinho
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
-
August 23rd, 2013, 11:42 AM
#10
Re: portable code
Originally Posted by Cambalinho
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
-
August 23rd, 2013, 12:16 PM
#11
Re: portable code
Originally Posted by Paul McKenzie
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
-
August 23rd, 2013, 12:36 PM
#12
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?
-
August 23rd, 2013, 01:17 PM
#13
Re: portable code
Originally Posted by Cambalinho
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
August 23rd, 2013, 01:30 PM
#14
Re: portable code
Originally Posted by 2kaud
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
-
August 23rd, 2013, 02:19 PM
#15
Re: portable code
Originally Posted by Cambalinho
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|