Starting with C or C++ or C#

Started by Baggey, December 02, 2021, 14:56:57

Previous topic - Next topic

Midimaster

BlitzMax (and other compiler languages ) are nowadays compared to C not longer so slow!!!

I think the reason why somebody uses C has changed. Now it is more the language to write libraries. C enables you to include the bindings for a lot of targets in your code, but makes the development volumious and complicate.

If you interested in the fastest or best libraries in the world, you need not to learn C, but you need how to bind them to your favorite language. See my Miniaudio-Wrapper.... It has 35.000 code lines in C but I needed only 50 code lines to use all it's functionality in BlitzMax.


...on the way to China.

Steve Elliott

Er excuse me. Blitzmax is mess compared to C. C++ has also become a mess so I would agree there - but not C.

Blitzmax is an abandoned language by it's creator.  The guy tried to please everybody so he added commands for people who couldn't be bothered to learn best practice regards basics like defining a variable type. So you get nonsense like strict and ultra strict, super strict or whatever it's called.  Oh please, define your language properly and don't create these massive inconsistencies.

You support Windows, Mac and Linux...But then abandon Linux, it becomes broken.  Oh great.

It's not weither a language is fast or slow, but that it's not dead, in active development and has good documentation, a good IDE - things of that nature.
Win11 64Gb 12th Gen Intel i9 12900K 5.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 4.4Ghz Nvidia RTX 2050 8Gb
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.6GHz Nvidia GeForce GTX 1050 2Gb
Linux Mint 8Gb Celeron 2.6Ghz UHD Graphics600
macOS 64Gb M4 Max 16C GPU 40C
Spectrum Next 2Mb

dawlane

#17
Quote from: Baggey on December 25, 2021, 20:10:27

I would love to have ago at C or C#. But these languages always end up with having to find out how to run make files. or find librarys then add path's, BUILD etc!

Imagine running BlitmaxC#.exe and IDE is ready togo with all of the commands ready togo!  :-X

GRAPHICS never seem to be out of the box! I know C is the closest thing to MachineCode! This means FAST!  :o

If i could i would like to setup let's say DEV-CPP, SDL, ALLEGRO and GLMax2D The most important thing is to be able to create a Full Screen On Windows!

Shame that cant ALL BE DONE in one .EXE i wouldn't use anything else if this was possible!  8)

But this is CHRISTMAS AFTER ALL! Just maybe. Just maybe someone out there knows how todo this!?

Kind Regards Baggey
From the context of the above. I get the impression that using C/C++ or any other general purpose programming language is maybe not for you.

For a general purpose programming language, you still have to pass information on how to compile the source code to the build system via the IDE. Or at some point, directly deal with a build system via the command line via the make application or the compiler it's self. Plus, C/C++ has a steep learning curve, jumping straight into using third-party libraries is not the best way to begin learning and using C/C++. Getting a couple of good books or find online material on beginning C/C++ would be the first place to start and if using the GNU tools such as make and GCC, look for material on those as well. Though if you are only programming for Windows, look for books or online for material on beginning C++ or C# with Visual Studio 2017 or later. There more tutorials on how to do things with Visual Studio and the programming languages it supports than any other IDE.

IDE's such as QtCreator from 'The Qt Company' are geared towards using their own Software Development Kit and only require that the basic tool chains are installed. You very rarely have to deal with the libraries that come with the compiler when using Qt, though using third-party libraries requires more work and knowledge of the build system. Visual Studio on the other hand, will have project templates that will set up most of the the build environment for you e.g. The nuget package manager. When it comes to other IDE's that are classed as light weight or simple. Then you're more likely have to do much more work.

In most cases, third-party libraries will have Visual Studio project templates you can use, or provide a script where a universal project generator such as CMAKE that can create the required project files.


zelda64bit

Quote from: Steve Elliott on December 25, 2021, 23:13:55
Er excuse me. Blitzmax is mess compared to C. C++ has also become a mess so I would agree there - but not C.

Blitzmax is an abandoned language by it's creator.  The guy tried to please everybody so he added commands for people who couldn't be bothered to learn best practice regards basics like defining a variable type. So you get nonsense like strict and ultra strict, super strict or whatever it's called.  Oh please, define your language properly and don't create these massive inconsistencies.

You support Windows, Mac and Linux...But then abandon Linux, it becomes broken.  Oh great.

It's not weither a language is fast or slow, but that it's not dead, in active development and has good documentation, a good IDE - things of that nature.

Would I like to know which are the languages that do not seem like a disaster to you?

Baggey

Hi, Ive Downloaded the SIDE Emulator Source file and am just trying to get it to work with Embacardo C++ anyone have any ideas just to compile and run.

Id like to learn from this.

https://www.syntaxbomb.com/blitzmax-blitzmax-ng/blitzmaxng-for-retro-coders!/new/#new

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

Steve Elliott

Quote
Would I like to know which are the languages that do not seem like a disaster to you?

;D Hehe, yeah I can be harsh out of frustration with some languages (especially if they are overly verbose in their syntax or have become overly complex and get ever larger).  And many are just general purpose languages, so to produce something with graphics or sound you have to bolt-on something else (which might not gel nicely with the language and add massively to the exe size).

In the end I designed my own language and am working away on that.  I don't have a release date other than 2022 right now.
Win11 64Gb 12th Gen Intel i9 12900K 5.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 4.4Ghz Nvidia RTX 2050 8Gb
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.6GHz Nvidia GeForce GTX 1050 2Gb
Linux Mint 8Gb Celeron 2.6Ghz UHD Graphics600
macOS 64Gb M4 Max 16C GPU 40C
Spectrum Next 2Mb

dawlane

#21
Quote from: Baggey on December 27, 2021, 16:20:38
Hi, Ive Downloaded the SIDE Emulator Source file and am just trying to get it to work with Embacardo C++ anyone have any ideas just to compile and run.

Id like to learn from this.

https://www.syntaxbomb.com/blitzmax-blitzmax-ng/blitzmaxng-for-retro-coders!/new/#new

Baggey
You need to set things up.
To keep it organised start by creating a new directory. This will be the root directory for all the files.

Create a new directory in the root directory called obj. This will hold the intermediary compiled object files that need to be linked later.

Extract the data.zip in the BlitzMax tutorial into the newly create root directory and rename the extracted directory to bin.

Extract the src directory from the side.zip into the newly created root directory.

Now the fun part.
Start Embacardo Dev-C++ and create and name a new empty C++ project. Then save the .dev file into the root directory the was created to hold all the files.
You'll then have the project listed in the Project pane on the left. Click the arrow at the side of the project name to expand the project tree and right click on the item with the name similar to untitled. It will show the context menu. Select Remove File to remover the empty file that will show up in the editor.

Now you need to add the source and header files. You can organise the projects tree using virtual folders. All you have to do to add one, is to right click on the project root node or a virtual folder and select Add Folder. To add the source files, either right click on the project root or virtual folder for a context menu, or select one of those nodes and use the Project sub menu from the main menu. In both menus, it will be listed as Add To Project.

When the Open File dialog box is shown, select all the files with the .cxx, .rc .h file extensions. Use the Open Files dialog's filter dropdown box to filter the file by extension types.

Now to set the project settings.
To access the project setting dialog, either right click on the project root, or use the Project sub menu in the main menu. It will be listed as Project Options.

In the first tab labelled General. Set the Type to Win32 GUI. For the Icon, click the Browse button and select the one in the previously extracted src directory.

The Parameters tab is where additional options can be set. The one of interest is the Linker input box. Add the following into it:
-Wl,--subsystem,windows
-lgdi32
-ldsound
-lwinmm


If you don't add these, you'll receive undefined reference errors from the linker.

The Output tab is where you redirect where files are built etc.
Set the following items...
Executable output directory: bin
Object file output directory: obj
These directories are the one that were created at the beginning.

The Directories tab is where you add search paths for external include files and libraries.
So the resource compiler can find the icon. The path needs to be added to the Resource Directories.
In the bottom text box type: src
Then click the add button.

Now a quick bit about the other tabs.
The Files tab is where you let the build system know which of the files add should be compiled.
The Compiler tab is where some initial options can be set.
The Makefile tab is if you intend to use a custom make file for the project instead of the IDE generated one.
The Version Info tab is where you can set your own version numbers for project build etc.

You could try to compile now, but the code is old and will fail to compile.
Line 450 will be the main issue. Comment out or remove the line and replace it with.

Code: BASIC
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow )


It should now compile with warnings about ISO C++ forbids converting a string constant to 'char*'.

To shut the compiler up. Line 66 needs to be changed from:
Code: BASIC
static char *   szSound[9] = {

to
Code: BASIC
static char const*   szSound[9] = {


And line 166 changed from
Code: BASIC
BOOL showError( char * msg )

to
Code: BASIC
BOOL showError( char const* msg )




Baggey

Quote from: Steve Elliott on December 27, 2021, 18:29:13
Quote
Would I like to know which are the languages that do not seem like a disaster to you?

;D Hehe, yeah I can be harsh out of frustration with some languages (especially if they are overly verbose in their syntax or have become overly complex and get ever larger).  And many are just general purpose languages, so to produce something with graphics or sound you have to bolt-on something else (which might not gel nicely with the language and add massively to the exe size).

In the end I designed my own language and am working away on that.  I don't have a release date other than 2022 right now.

In the end I designed my own language and am working away on that.  I don't have a release date other than 2022 right now.

That's one BIG KUDOS hope you've been reading about my fustrations with some language's! :o

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey

Quote from: dawlane on December 27, 2021, 22:14:05
Quote from: Baggey on December 27, 2021, 16:20:38
Hi, Ive Downloaded the SIDE Emulator Source file and am just trying to get it to work with Embacardo C++ anyone have any ideas just to compile and run.

Id like to learn from this.

https://www.syntaxbomb.com/blitzmax-blitzmax-ng/blitzmaxng-for-retro-coders!/new/#new

Baggey
You need to set things up.
To keep it organised start by creating a new directory. This will be the root directory for all the files.

Create a new directory in the root directory called obj. This will hold the intermediary compiled object files that need to be linked later.

Extract the data.zip in the BlitzMax tutorial into the newly create root directory and rename the extracted directory to bin.

Extract the src directory from the side.zip into the newly created root directory.

Now the fun part.
Start Embacardo Dev-C++ and create and name a new empty C++ project. Then save the .dev file into the root directory the was created to hold all the files.
You'll then have the project listed in the Project pane on the left. Click the arrow at the side of the project name to expand the project tree and right click on the item with the name similar to untitled. It will show the context menu. Select Remove File to remover the empty file that will show up in the editor.

Now you need to add the source and header files. You can organise the projects tree using virtual folders. All you have to do to add one, is to right click on the project root node or a virtual folder and select Add Folder. To add the source files, either right click on the project root or virtual folder for a context menu, or select one of those nodes and use the Project sub menu from the main menu. In both menus, it will be listed as Add To Project.

When the Open File dialog box is shown, select all the files with the .cxx, .rc .h file extensions. Use the Open Files dialog's filter dropdown box to filter the file by extension types.

Now to set the project settings.
To access the project setting dialog, either right click on the project root, or use the Project sub menu in the main menu. It will be listed as Project Options.

In the first tab labelled General. Set the Type to Win32 GUI. For the Icon, click the Browse button and select the one in the previously extracted src directory.

The Parameters tab is where additional options can be set. The one of interest is the Linker input box. Add the following into it:
-Wl,--subsystem,windows
-lgdi32
-ldsound
-lwinmm


If you don't add these, you'll receive undefined reference errors from the linker.

The Output tab is where you redirect where files are built etc.
Set the following items...
Executable output directory: bin
Object file output directory: obj
These directories are the one that were created at the beginning.

The Directories tab is where you add search paths for external include files and libraries.
So the resource compiler can find the icon. The path needs to be added to the Resource Directories.
In the bottom text box type: src
Then click the add button.

Now a quick bit about the other tabs.
The Files tab is where you let the build system know which of the files add should be compiled.
The Compiler tab is where some initial options can be set.
The Makefile tab is if you intend to use a custom make file for the project instead of the IDE generated one.
The Version Info tab is where you can set your own version numbers for project build etc.

You could try to compile now, but the code is old and will fail to compile.
Line 450 will be the main issue. Comment out or remove the line and replace it with.

Code: BASIC
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow )


It should now compile with warnings about ISO C++ forbids converting a string constant to 'char*'.

To shut the compiler up. Line 66 needs to be changed from:
Code: BASIC
static char *   szSound[9] = {

to
Code: BASIC
static char const*   szSound[9] = {


And line 166 changed from
Code: BASIC
BOOL showError( char * msg )

to
Code: BASIC
BOOL showError( char const* msg )


Im Currently working through above  ;D

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey

#24
So,
     I have Directory created in the root of C:\ Drive called "Obj" with data extracted to one level of data only.

    and ive renamed it to bin, now done the src ZIP from side.

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey

#25
So, Ive got this far

What do i do with the Project root node. I sort of wanna just drag and drop Obj here?

Am i just adding the Dev arcade file?

Baggey

Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

dawlane

#26
Quote from: Baggey on December 28, 2021, 14:47:54
So,
     I have Directory created in the root of C:\ Drive called "Obj" with data extracted to one level of data only.

    and ive renamed it to bin, now done the src ZIP from side.

Baggey
The directory structure on disk needs to be:
project_root_directory
                                 bin
                                 obj
                                 src
                                 project.dev

project_root_dirctory: container for the Dev-C++ project files and all the other associated files.
bin: contains the sounds and rom files and where the final executable will be placed.
obj: will be where the the compiler stores it's intermediary build file.
src: will contain all source files.
project.dev: will be the Dev-C++ project file.

dawlane

Quote from: Baggey on December 28, 2021, 15:09:25
So, Ive got this far

What do i do with the Project root node. I sort of wanna just drag and drop Obj here?

Am i just adding the Dev arcade file?

Baggey
No. You select the the Add To Project. It opens a file dialog where find and select the the files from the src directory.

Baggey

Quote from: dawlane on December 28, 2021, 15:15:22
Quote from: Baggey on December 28, 2021, 15:09:25
So, Ive got this far

What do i do with the Project root node. I sort of wanna just drag and drop Obj here?

Am i just adding the Dev arcade file?

Baggey
No. You select the the Add To Project. It opens a file dialog where find and select the the files from the src directory.

Please berewith. I have this now :-X

Kindest Regards Baggey

Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

Baggey

I have the files added now. At least i think i do.

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!