Author Topic: DECLARE LIBRARY adding extra slashes to paths  (Read 4256 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
DECLARE LIBRARY adding extra slashes to paths
« on: December 15, 2021, 08:50:17 am »
  [ You are not allowed to view this attachment ]  
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: DECLARE LIBRARY adding extra slashes to paths
« Reply #1 on: December 15, 2021, 09:00:14 am »
They're needed internally (first backslash is an escape char) - you'll notice the extra ",14" indicating the length of the string. That's internal compiler intermediate representation, no need to worry about it.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: DECLARE LIBRARY adding extra slashes to paths
« Reply #2 on: December 15, 2021, 09:09:49 am »
Except it's not finding the library which is right where it should be. 

If mem.h is moved into the same directory as the EXE, it'll find it with a path of "./mem", but it won't find it if we just DECLARE LIBRARY "mem".

Something isn't pathing as it should be properly.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: DECLARE LIBRARY adding extra slashes to paths
« Reply #3 on: December 15, 2021, 09:15:03 am »
To add to the oddity, this works:

Code: QB64: [Select]
  1.     $ExeIcon:'.\chessdat\chess.ico'
  2.     Const slash = "\"
  3.     Declare Library ".\chess\chessdat\mem" ' S McNeill CPU load tracking, Linux uses sensors
  4.         Function GetCPULoad#
  5.     End Declare

Notice the $EXEIcon has no problem finding the resource based off from where the .BAS file is located.  (It's in the /chess folder.)

The call to DECLARE LIBRARY, however, needs a path to be in relation to QB64.EXE, rather than where the chess.BAS is located.

It doesn't appear that DECLARE LIBRARY is looking for files in relation to the source code's folder, even if Export EXE to Source Folder is selected in the options.

To sum up the odd behavior I'm seeing here:

".\mem" *will* look in the folder with the BAS file and find our header file.
"mem" doesn't, though it seems like it should default to the same directory as the BAS file.
".\chessdat\mem" doesn't find the file, even though there's a copy of it inside the "chessdat" folder.  For whatever reason, it can't find the relative folder and the file inside it.
« Last Edit: December 15, 2021, 09:20:29 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: DECLARE LIBRARY adding extra slashes to paths
« Reply #4 on: December 15, 2021, 10:33:54 am »
Path resolution for declare blocks is a known issue, open at the repository as we speak. If you do any work on it before we do, let us know.

FellippeHeitor

  • Guest

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: DECLARE LIBRARY adding extra slashes to paths
« Reply #6 on: December 15, 2021, 12:23:42 pm »
Path resolution for declare blocks is a known issue, open at the repository as we speak. If you do any work on it before we do, let us know.

My schedule more-or-less frees up starting around mid-January.  If no one's dug into it before then, I'll see what I can find with it.  I'd never had issues with the before, so wasn't aware it was an issue for us.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
Re: DECLARE LIBRARY adding extra slashes to paths
« Reply #7 on: December 15, 2021, 12:29:34 pm »
Couldn't you use a ../ like you can when you have an INCLUDE?

For example:
Code: QB64: [Select]
  1. endPROG:
  2. ' *** CLOSE Log File
  3. '
  4.  
  5. ' *** Remove work files if they exist
  6. '$INCLUDE: '../include/deleteWorkFiles.inc'    
  7.     PRINT #flog%, ">>>>> Executing endPROG"
  8.     PRINT #flog%, ""
  9.     PRINT #flog%, "": PRINT #flog%, "*** " + ProgramName$ + " - Terminated Normally ***"
  10.     CLOSE #flog%
  11.     SYSTEM

The code snippet is part of a SUB located in the /include directory, because it is used in 3 programs. the deleteWorkFiles.inc is used in many of my programs in the project directory.

I've never tried this with DECLARE LIBRARY statements before, but wouldn't it still resolve correctly?
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)