Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling functions in C++ from C

21 views
Skip to first unread message

Bertram

unread,
Oct 15, 2012, 9:25:07 AM10/15/12
to

Hi all

I trying to use the functions of the C++ and Windows for read
and send the text to the clipboard, with the Mingw compiler.

I saw that there are header files that contain as Winuser.he Windows.h
functions to use the clipboard.

Question: as invoke a C++ function, in C?,

How do I make a call to this function?

WINUSERAPI BOOL WINAPI CloseClipboard (void);
WINUSERAPI HANDLE WINAPI GetClipboardData (UINT);
WINUSERAPI BOOL WINAPI OpenClipboard (HWND);
WINUSERAPI HANDLE WINAPI SetClipboardData (UINT, HANDLE);

Greetings



Kuroneko

unread,
Oct 15, 2012, 9:59:32 AM10/15/12
to
Why not just make it a C++ file? C code will work in a C++ file, and you'll be able to use C++ as well, since C++ includes all of C.

Ben Bacarisse

unread,
Oct 15, 2012, 11:10:39 AM10/15/12
to
Kuroneko <zeng.a...@gmail.com> writes:
<snip>
> Why not just make it a C++ file? C code will work in a C++ file, and
> you'll be able to use C++ as well, since C++ includes all of C.

C++ does not include all of C. I don't want to make too much of this
because it includes a lot of C (especially if your idea of C was frozen
in 1990) but there are just enough differences to trip up the unwary.

--
Ben.

ralph

unread,
Oct 15, 2012, 11:42:47 AM10/15/12
to
On Mon, 15 Oct 2012 15:25:07 +0200, "Bertram" <nos...@nospam.org>
wrote:
Probably need more information since I can't see the problem.
Simply include the Windows headers and have at it.

You can can download the Windows Win32 API files in a package from the
Mingw site. (Or from Microsoft).

-ralph

Bertram

unread,
Oct 15, 2012, 12:47:36 PM10/15/12
to

I have a programm console, write in C, for read clipboard, I must add
options for send data to clipboard.


>You can can download the Windows Win32 API files in a package from the
>Mingw site. (Or from Microsoft).

From MinGW, no. You have link for this package?

Thanks

Regards




Kuroneko

unread,
Oct 15, 2012, 2:05:44 PM10/15/12
to
On Monday, 15 October 2012 11:10:45 UTC-4, Ben Bacarisse wrote:
> C++ does not include all of C.

Wait, really? What are some C features not included in C++? Or are they rarely used and not well known?

Ike Naar

unread,
Oct 15, 2012, 3:37:13 PM10/15/12
to
For instance, variable length arrays.

If you're interested, see David Tribble's page:
http://david.tribble.com/text/cdiffs.htm

ralph

unread,
Oct 15, 2012, 3:52:26 PM10/15/12
to
On Mon, 15 Oct 2012 18:47:36 +0200, "Bertram" <nos...@nospam.org>
wrote:
http://sourceforge.net/projects/mingw/

Take a look at this page for the basics.
http://osix.net/modules/article/?id=670

When you read that article note the difference between what the author
calls the "DOS Box" and a "Windows program". You used the term
"program console", but there are actually two kinds of "console"
programs that can be run within a "DOS Box".

The first type is as shown first in the article.
This is creates a program which will run in a "DOS subsystem", and
uses the basic Character-based I/O. This will not create a "Windows
program" and will be unable to use many of the Windows-specific
features. ie, expect to be surprised. <g>

The second is an application that is a "Windows Console". This is a
true Windows application and can use most of the Windows-specific
features.

http://msdn.microsoft.com/en-us/library/ms682010(v=vs.85).aspx

If you post any additional problems please be sure to mention which
Windows Console application you are using.

-ralph

Ben Bacarisse

unread,
Oct 15, 2012, 4:05:16 PM10/15/12
to
There are number differences that could come lead one to say that C++
does not include all of C:

(a) There are things that C++ has added that make some C programs
illegal. The most obvious being all the extra keywords that C++ has.

(b) There are things that C has added that never got taken up by C++:
variably modified arrays, compound literals, the restrict qualifier,
_Generic expressions, and so on.

(c) There are things that the two languages simply do differently. The
classic example is the type of a character literal, but there are other
more substantive differences such as the way complex numbers are
implemented.

I leave it to you to decide if all or any of these are rarely used
and/or not well known -- I really have no idea.

--
Ben.

Kuroneko

unread,
Oct 15, 2012, 4:07:10 PM10/15/12
to
Ah, I see. Yes, it appears my ideas of C are quite old.

Keith Thompson

unread,
Oct 15, 2012, 7:09:46 PM10/15/12
to
Among other things, C++ has a number of keywords that C lacks.
Any C program that uses "class" as an identifier, for example, won't
compile as C++. (Some programmers do this deliberately to make sure
you use the right compiler for the language the code is written in.)

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Bertram

unread,
Oct 16, 2012, 7:27:53 AM10/16/12
to

Many thanks.

Greetings


0 new messages