Like Tree3Likes
  • 2 Post By phantomotap
  • 1 Post By stahta01

Making my own version of the scanf() version

This is a discussion on Making my own version of the scanf() version within the C Programming forums, part of the General Programming Boards category; Hi guys, This is sort of two questions in one really XD. I'm trying to make an OS using C. ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Location
    Cwmbran, South Wales
    Posts
    16

    Making my own version of the scanf() version

    Hi guys,

    This is sort of two questions in one really XD.

    I'm trying to make an OS using C. Which is a real challenge as I'm more of a C++ kinda guy, anyway.

    How would I be able to create a scanf() type function? The reason I'm asking is because, as you may know, when making an OS you can't include system headers ( you know the #include < > ones ). Is there a way of doing this without the system headers?

    And a second, less important question is, how would I be able to incorporate C++ into the C kernel? I.e. make a c++ function, and then call it from within the C main() function? ( If this can be answered then it could make my life easier with the scanf problem as I could use std::cin instead. ).

    Thanks in advance.

    Jamie.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,571
    Writing the C++ standard libraries is very likely much harder than writing the C standard libraries.

    I suggest reading stuff in OSDev.org &bull; Index page forums.
    http://wiki.osdev.org/Main_Page

    Tim S.
    Last edited by stahta01; 04-29-2012 at 02:35 PM. Reason: spelling
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,247
    I'm trying to make an OS using C. Which is a real challenge as I'm more of a C++ kinda guy, anyway.
    O_o

    How would I be able to create a scanf() type function?
    O_o

    Is there a way of doing this without the system headers?
    O_o

    If this can be answered then it could make my life easier with the scanf problem as I could use std::cin instead.
    O_o

    You have no business making a kernel.

    You are so incredibly not ready for the task you've set yourself.

    Pull your head from your ... and read a book on programming.

    Soma
    memcpy and dennis.cpp like this.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    in the C++ file you declare your function 'extern "C" <function declaration>'. this tells the C++ compiler to use C linkage. then a C program can call it. it has to be a plain old function and it can't use any C++ features in the function declaration.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    2,571
    Quote Originally Posted by dmh2000 View Post
    in the C++ file you declare your function 'extern "C" <function declaration>'. this tells the C++ compiler to use C linkage. then a C program can call it. it has to be a plain old function and it can't use any C++ features in the function declaration.
    Link about this.
    [32] How to mix C and C++ ..Updated!.., C++ FAQ

    Tim S.
    dmh2000 likes this.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Gcc Version
    By kris.c in forum Tech Board
    Replies: 2
    Last Post: 07-04-2006, 09:37 AM
  2. Dev C++ version 4
    By Finchie_88 in forum C++ Programming
    Replies: 2
    Last Post: 12-19-2004, 11:55 AM
  3. version?
    By moi in forum Windows Programming
    Replies: 3
    Last Post: 11-27-2002, 04:10 AM
  4. GLH Version 1.4
    By Eber Kain in forum Game Programming
    Replies: 0
    Last Post: 11-14-2001, 12:44 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21