Click here to Skip to main content
16,011,870 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCommand Line problems Pin
20-Jun-01 4:09
suss20-Jun-01 4:09 
GeneralRe: Command Line problems Pin
Chris Losinger20-Jun-01 4:38
professionalChris Losinger20-Jun-01 4:38 
GeneralRe: Command Line problems Pin
Carlos Antollini20-Jun-01 4:48
Carlos Antollini20-Jun-01 4:48 
GeneralRe: Command Line problems Pin
20-Jun-01 5:04
suss20-Jun-01 5:04 
GeneralRe: Command Line problems Pin
Chris Losinger20-Jun-01 5:10
professionalChris Losinger20-Jun-01 5:10 
GeneralRe: Command Line problems Pin
20-Jun-01 5:24
suss20-Jun-01 5:24 
GeneralRe: Command Line problems Pin
Chris Losinger20-Jun-01 7:38
professionalChris Losinger20-Jun-01 7:38 
GeneralProblems using functions in structs in MSVC++ Pin
Jason Hihn20-Jun-01 3:52
Jason Hihn20-Jun-01 3:52 
I am attempting to write a C library of routines for my DVD player. (It talks over a serial port.) I want the library as portable as possible, so I'm attempting to do it in C. I know it'd be alot easier for me to do it with classes, but as far as I'm concerened, C++ is out of the question.

I can successfully compile the header below with it's .c file. The problem comes when other C++ modules (I'm trying to use the C library in an MFC app) #include the header. The compiler chokes on the first paranthesis inside the struct definition. I'm thinking it's something having to do with switching into C++ mode.

The whole reason why I'm doing this is because I don't want the user to have to mess with a buffer. All they need to provide are callbacks for Open, Close, Read, and Write (reguarldess if they are using J.P. Naughter's serial wrappers, raw win32 api, or Unix file i/o) of the serial port library and users can do something simple like: DVDPlayer.Execute(PLAY); and not have to worry themselves with formatting, writing and returning the response to me for parsing. This way, it can all be handled internally. And in C.

[ccode]
#pragma once

int DVF07Error(struct DVF07*);
void DVF07StoreTOC(struct DVF07*, struct toc_type*);
void DVF07StoreTrack(struct DVF07*, struct toc_type*, int);
void DVF07TraceTOC(struct toc_type*);
int DVF07Format(struct DVF07*, int, int);
int DVF07Execute(struct DVF07*, int, int);
int DVF07ReturnedInt(struct DVF07*);
int DVF07SizeofBuf(struct DVF07*);

typedef struct DVF07{
/* in c++ files, when this is #included, the ( of int (*Error is */
/* where the compiler chokes, but it compiles fine when */
/* the .c file #includes it */
int (*Error)(struct DFV07 *this);
void (*StoreTOC)(struct toc_type*, struct *toc_type);
void (*StoreTrack)(struct toc_type*, int i);
void (*TraceTOC)(struct toc_type *toc);
int (*Format)(struct DVF07 *this, int, int);
int (*Execute)(struct DVF07 *this, int, int);
int (*ReturnedInt)(struct DVF07 *this);
int (*SizeOfBuf)(struct DVF07 *this);
/* user provided routines below */
int (*Write)(struct DVF07 *this);
int (*Read) (struct DVF07 *this);
int (*Open) (struct DVF07 *this, int port);
int (*Close)(struct DVF07 *this);

char buf[256];
} DVF07_Type;

[/ccode]
GeneralRe: Problems using functions in structs in MSVC++ Pin
Dark Angel20-Jun-01 4:08
Dark Angel20-Jun-01 4:08 
GeneralRe: Problems using functions in structs in MSVC++ Pin
Jason Hihn20-Jun-01 7:00
Jason Hihn20-Jun-01 7:00 
GeneralRe: Problems using functions in structs in MSVC++ Pin
Ben Burnett20-Jun-01 7:32
Ben Burnett20-Jun-01 7:32 
GeneralRe: Problems using functions in structs in MSVC++ Pin
Jason Hihn20-Jun-01 8:21
Jason Hihn20-Jun-01 8:21 
GeneralMy documents directory Pin
jerry0davis20-Jun-01 3:37
jerry0davis20-Jun-01 3:37 
GeneralRe: My documents directory Pin
Matt Gullett20-Jun-01 3:44
Matt Gullett20-Jun-01 3:44 
GeneralRe: My documents directory Pin
jerry0davis20-Jun-01 3:48
jerry0davis20-Jun-01 3:48 
QuestionGetWindowLong????? Pin
20-Jun-01 3:00
suss20-Jun-01 3:00 
Generalsimple array question Pin
20-Jun-01 2:44
suss20-Jun-01 2:44 
GeneralRe: simple array question Pin
20-Jun-01 3:22
suss20-Jun-01 3:22 
GeneralRe: simple array question Pin
20-Jun-01 3:31
suss20-Jun-01 3:31 
GeneralRe: simple array question Pin
20-Jun-01 17:46
suss20-Jun-01 17:46 
GeneralMDI and WS_MAXIMIZE,, Please Pin
mr200320-Jun-01 2:29
mr200320-Jun-01 2:29 
GeneralRe: MDI and WS_MAXIMIZE,, Please Pin
20-Jun-01 3:06
suss20-Jun-01 3:06 
GeneralRe: MDI and WS_MAXIMIZE,, Please Pin
mr200320-Jun-01 3:16
mr200320-Jun-01 3:16 
GeneralRe: MDI and WS_MAXIMIZE,, Please Pin
20-Jun-01 4:09
suss20-Jun-01 4:09 
GeneralVirtual Functions Pin
20-Jun-01 1:35
suss20-Jun-01 1:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.